Skip to content

Commit c87ec60

Browse files
committed
fix guide
1 parent 541786e commit c87ec60

File tree

3 files changed

+43
-24
lines changed

3 files changed

+43
-24
lines changed

docs/interactions/ui-components/dropdowns.mdx

+1-1
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

+1
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

+41-23
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
```

0 commit comments

Comments
 (0)