Skip to content

Commit 81c2b33

Browse files
committed
fix guide
1 parent 541786e commit 81c2b33

File tree

10 files changed

+52
-34
lines changed

10 files changed

+52
-34
lines changed

.github/workflows/codespell.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ jobs:
1010
with:
1111
python-version: "3.x"
1212
- run: pip install codespell
13-
- run: codespell --ignore-words-list="groupt,nd,ot,claus" --skip="./yarn.lock"
13+
- run: codespell --ignore-words-list="groupt,nd,ot,claus,everytime" --skip="./yarn.lock"

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v4
16-
- uses: actions/setup-node@v3
16+
- uses: actions/setup-node@v4
1717
with:
1818
node-version: 18
1919
cache: yarn

.github/workflows/devskim.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ on:
1616
jobs:
1717
lint:
1818
name: DevSkim
19-
runs-on: ubuntu-20.04
19+
runs-on: ubuntu-latest
2020
permissions:
2121
actions: read
2222
contents: read

.github/workflows/node.js.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
node-version: [16.14]
15+
node-version: [18]
1616
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
1717

1818
steps:
1919
- uses: actions/checkout@v4
2020
- name: Use Node.js ${{ matrix.node-version }}
21-
uses: actions/setup-node@v3
21+
uses: actions/setup-node@v4
2222
with:
2323
node-version: ${{ matrix.node-version }}
2424
cache: 'yarn'

.github/workflows/test-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- uses: actions/checkout@v4
19-
- uses: actions/setup-node@v3
19+
- uses: actions/setup-node@v4
2020
with:
2121
node-version: 18
2222
cache: yarn

docs/interactions/ui-components/dropdowns.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class MyView(discord.ui.View):
5151

5252
@bot.command()
5353
async def flavor(ctx):
54-
await ctx.send("Choose a flavor!", view=MyView())
54+
await ctx.respond("Choose a flavor!", view=MyView())
5555

5656
bot.run("TOKEN")
5757
```

docs/more/community-resources.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ This page showcases the amazing things created by the Pycord community, includin
1717

1818
| Name | Type | Link |
1919
| ------------------------ | ------------ | ----------------------------------------------------------------------------------- |
20+
| CookieBot | Multipurpose | [website](https://cookie-bot.xyz) |
2021
| Discord-Multipurpose-Bot | Multipurpose | [github](https://github.com/pogrammar/Discord-multipurpose-bot/tree/master/Python) |
2122
| _GZ_ Global | Chatting | [website](https://www.gzglobal.eu/) |
2223
| inconnu | Fun & QOL | [github](https://github.com/tiltowait/inconnu) |

docs/voice/playing.mdx

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,15 @@ async def connect_nodes():
4747
"""Connect to our Lavalink nodes."""
4848
await bot.wait_until_ready() # wait until the bot is ready
4949

50-
await wavelink.NodePool.create_node(
51-
bot=bot,
52-
host='0.0.0.0',
53-
port=2333,
54-
password='youshallnotpass'
55-
) # create a node
50+
nodes = [
51+
wavelink.Node(
52+
identifier="Node1", # This identifier must be unique for all the nodes you are going to use
53+
uri="http://0.0.0.0:443", # Protocol (http/s) is required, port must be 443 as it is the one lavalink uses
54+
password="youshallnotpass"
55+
)
56+
]
57+
58+
await wavelink.Pool.connect(nodes=nodes, client=bot) # Connect our nodes
5659
```
5760

5861
<br />
@@ -67,23 +70,35 @@ Now you are finished making your node! Next, you will want to:
6770
To make a play command, you will need to make a function to connect and play audio in a voice channel.
6871

6972
```py title="Play Command Example"
73+
import typing
74+
7075
@bot.slash_command(name="play")
7176
async def play(ctx, search: str):
72-
vc = ctx.voice_client # define our voice client
73-
74-
if not vc: # check if the bot is not in a voice channel
75-
vc = await ctx.author.voice.channel.connect(cls=wavelink.Player) # connect to the voice channel
76-
77-
if ctx.author.voice.channel.id != vc.channel.id: # check if the bot is not in the voice channel
78-
return await ctx.respond("You must be in the same voice channel as the bot.") # return an error message
79-
80-
song = await wavelink.YouTubeTrack.search(query=search, return_first=True) # search for the song
81-
82-
if not song: # check if the song is not found
83-
return await ctx.respond("No song found.") # return an error message
84-
85-
await vc.play(song) # play the song
86-
await ctx.respond(f"Now playing: `{vc.source.title}`") # return a message
77+
# First we may define our voice client,
78+
# for this, we are going to use typing.cast()
79+
# function just for the type checker know that
80+
# `ctx.voice_client` is going to be from type
81+
# `wavelink.Player`
82+
vc = typing.cast(wavelink.Player, ctx.voice_client)
83+
84+
if not vc: # We firstly check if there is a voice client
85+
vc = await ctx.author.voice.channel.connect(cls=wavelink.Player) # If there isn't, we connect it to the channel
86+
87+
# Now we are going to check if the invoker of the command
88+
# is in the same voice channel than the voice client, when defined.
89+
# If not, we return an error message.
90+
if ctx.author.voice.channel.id != vc.channel.id:
91+
return await ctx.respond("You must be in the same voice channel as the bot.")
92+
93+
# Now we search for the song. You can optionally
94+
# pass the "source" keyword, of type "wavelink.TrackSource"
95+
song = await wavelink.Playable.search(search)
96+
97+
if not song: # In case the song is not found
98+
return await ctx.respond("No song found.") # we return an error message
99+
100+
await vc.play(song) # Else, we play it
101+
await ctx.respond(f"Now playing: `{song.title}`") # and return a success message
87102
```
88103

89104
<DiscordComponent>
@@ -113,8 +128,11 @@ async def on_ready():
113128
await connect_nodes() # connect to the server
114129

115130
@bot.event
116-
async def on_wavelink_node_ready(node: wavelink.Node):
117-
print(f"{node.identifier} is ready.") # print a message
131+
async def on_wavelink_node_ready(payload: wavelink.NodeReadyEventPayload):
132+
# Everytime a node is successfully connected, we
133+
# will print a message letting it know.
134+
print(f"Node with ID {payload.session_id} has connected")
135+
print(f"Resumed session: {payload.resumed}")
118136

119137
bot.run("token")
120138
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"@mdx-js/react": "1.6.22",
3434
"@types/react": "17.0.2",
3535
"clsx": "2.0.0",
36-
"discord-message-components": "https://gitpkg.now.sh/Pycord-Development/discord-message-components?aa468ada9b2b52986ae0aee4051660713c1e9095&scripts.postinstall=yarn%20install%20--ignore-scripts%20%26%26%20node%20node_modules%2Fesbuild%2Finstall.js%20%26%26yarn%20build%3Amarkdown%20%26%26%20yarn%20build%3Acore%20%26%26%20yarn%20build%3Areact",
36+
"discord-message-components": "https://gitpkg.now.sh/Pycord-Development/discord-message-components?aa468ada9b2b52986ae0aee4051660713c1e9095&scripts.postinstall=yarn%20install%20--ignore-scripts%20%26%26%20node%20node_modules%2Fesbuild%2Finstall.js%20%26%26yarn%20build%3Amarkdown%20%26%26%20yarn%20build%3Acore%20%26%26%20yarn%20build%3Areact%20%26%26",
3737
"docusaurus-plugin-sass": "0.2.5",
3838
"prism-react-renderer": "1.3.5",
3939
"react": "17.0.2",

yarn.lock

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,7 +1434,6 @@
14341434

14351435
"@discordapp/twemoji@discord/twemoji":
14361436
version "14.1.2"
1437-
uid c9fb242544b5f9068221d3baadb3b5d7ec9727c0
14381437
resolved "https://codeload.github.com/discord/twemoji/tar.gz/c9fb242544b5f9068221d3baadb3b5d7ec9727c0"
14391438
dependencies:
14401439
fs-extra "^8.0.1"
@@ -3985,9 +3984,9 @@ dir-glob@^3.0.1:
39853984
dependencies:
39863985
path-type "^4.0.0"
39873986

3988-
"discord-message-components@https://gitpkg.now.sh/Pycord-Development/discord-message-components?aa468ada9b2b52986ae0aee4051660713c1e9095&scripts.postinstall=yarn%20install%20--ignore-scripts%20%26%26%20node%20node_modules%2Fesbuild%2Finstall.js%20%26%26yarn%20build%3Amarkdown%20%26%26%20yarn%20build%3Acore%20%26%26%20yarn%20build%3Areact":
3987+
"discord-message-components@https://gitpkg.now.sh/Pycord-Development/discord-message-components?aa468ada9b2b52986ae0aee4051660713c1e9095&scripts.postinstall=yarn%20install%20--ignore-scripts%20%26%26%20node%20node_modules%2Fesbuild%2Finstall.js%20%26%26yarn%20build%3Amarkdown%20%26%26%20yarn%20build%3Acore%20%26%26%20yarn%20build%3Areact%20%26%26":
39893988
version "0.0.0"
3990-
resolved "https://gitpkg.now.sh/Pycord-Development/discord-message-components?aa468ada9b2b52986ae0aee4051660713c1e9095&scripts.postinstall=yarn%20install%20--ignore-scripts%20%26%26%20node%20node_modules%2Fesbuild%2Finstall.js%20%26%26yarn%20build%3Amarkdown%20%26%26%20yarn%20build%3Acore%20%26%26%20yarn%20build%3Areact#d91f955d42a5d27381cb4af5d7d6c290122ad45f"
3989+
resolved "https://gitpkg.now.sh/Pycord-Development/discord-message-components?aa468ada9b2b52986ae0aee4051660713c1e9095&scripts.postinstall=yarn%20install%20--ignore-scripts%20%26%26%20node%20node_modules%2Fesbuild%2Finstall.js%20%26%26yarn%20build%3Amarkdown%20%26%26%20yarn%20build%3Acore%20%26%26%20yarn%20build%3Areact%20%26%26#b9976a195da1dfaf42fffe712a0ca743076971f3"
39913990

39923991
dns-equal@^1.0.0:
39933992
version "1.0.0"

0 commit comments

Comments
 (0)