Skip to content

Commit

Permalink
fix guide
Browse files Browse the repository at this point in the history
  • Loading branch information
Lulalaby committed Apr 18, 2024
1 parent 541786e commit 81c2b33
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ jobs:
with:
python-version: "3.x"
- run: pip install codespell
- run: codespell --ignore-words-list="groupt,nd,ot,claus" --skip="./yarn.lock"
- run: codespell --ignore-words-list="groupt,nd,ot,claus,everytime" --skip="./yarn.lock"
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18
cache: yarn
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/devskim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
jobs:
lint:
name: DevSkim
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ jobs:

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

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18
cache: yarn
Expand Down
2 changes: 1 addition & 1 deletion docs/interactions/ui-components/dropdowns.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class MyView(discord.ui.View):

@bot.command()
async def flavor(ctx):
await ctx.send("Choose a flavor!", view=MyView())
await ctx.respond("Choose a flavor!", view=MyView())

bot.run("TOKEN")
```
Expand Down
1 change: 1 addition & 0 deletions docs/more/community-resources.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ This page showcases the amazing things created by the Pycord community, includin

| Name | Type | Link |
| ------------------------ | ------------ | ----------------------------------------------------------------------------------- |
| CookieBot | Multipurpose | [website](https://cookie-bot.xyz) |
| Discord-Multipurpose-Bot | Multipurpose | [github](https://github.com/pogrammar/Discord-multipurpose-bot/tree/master/Python) |
| _GZ_ Global | Chatting | [website](https://www.gzglobal.eu/) |
| inconnu | Fun & QOL | [github](https://github.com/tiltowait/inconnu) |
Expand Down
64 changes: 41 additions & 23 deletions docs/voice/playing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,15 @@ async def connect_nodes():
"""Connect to our Lavalink nodes."""
await bot.wait_until_ready() # wait until the bot is ready

await wavelink.NodePool.create_node(
bot=bot,
host='0.0.0.0',
port=2333,
password='youshallnotpass'
) # create a node
nodes = [
wavelink.Node(
identifier="Node1", # This identifier must be unique for all the nodes you are going to use
uri="http://0.0.0.0:443", # Protocol (http/s) is required, port must be 443 as it is the one lavalink uses
password="youshallnotpass"
)
]

await wavelink.Pool.connect(nodes=nodes, client=bot) # Connect our nodes
```

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

```py title="Play Command Example"
import typing

@bot.slash_command(name="play")
async def play(ctx, search: str):
vc = ctx.voice_client # define our voice client

if not vc: # check if the bot is not in a voice channel
vc = await ctx.author.voice.channel.connect(cls=wavelink.Player) # connect to the voice channel

if ctx.author.voice.channel.id != vc.channel.id: # check if the bot is not in the voice channel
return await ctx.respond("You must be in the same voice channel as the bot.") # return an error message

song = await wavelink.YouTubeTrack.search(query=search, return_first=True) # search for the song

if not song: # check if the song is not found
return await ctx.respond("No song found.") # return an error message

await vc.play(song) # play the song
await ctx.respond(f"Now playing: `{vc.source.title}`") # return a message
# First we may define our voice client,
# for this, we are going to use typing.cast()
# function just for the type checker know that
# `ctx.voice_client` is going to be from type
# `wavelink.Player`
vc = typing.cast(wavelink.Player, ctx.voice_client)

if not vc: # We firstly check if there is a voice client
vc = await ctx.author.voice.channel.connect(cls=wavelink.Player) # If there isn't, we connect it to the channel

# Now we are going to check if the invoker of the command
# is in the same voice channel than the voice client, when defined.
# If not, we return an error message.
if ctx.author.voice.channel.id != vc.channel.id:
return await ctx.respond("You must be in the same voice channel as the bot.")

# Now we search for the song. You can optionally
# pass the "source" keyword, of type "wavelink.TrackSource"
song = await wavelink.Playable.search(search)

if not song: # In case the song is not found
return await ctx.respond("No song found.") # we return an error message

await vc.play(song) # Else, we play it
await ctx.respond(f"Now playing: `{song.title}`") # and return a success message
```

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

@bot.event
async def on_wavelink_node_ready(node: wavelink.Node):
print(f"{node.identifier} is ready.") # print a message
async def on_wavelink_node_ready(payload: wavelink.NodeReadyEventPayload):
# Everytime a node is successfully connected, we
# will print a message letting it know.
print(f"Node with ID {payload.session_id} has connected")
print(f"Resumed session: {payload.resumed}")

bot.run("token")
```
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@mdx-js/react": "1.6.22",
"@types/react": "17.0.2",
"clsx": "2.0.0",
"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",
"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",
"docusaurus-plugin-sass": "0.2.5",
"prism-react-renderer": "1.3.5",
"react": "17.0.2",
Expand Down
5 changes: 2 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1434,7 +1434,6 @@

"@discordapp/twemoji@discord/twemoji":
version "14.1.2"
uid c9fb242544b5f9068221d3baadb3b5d7ec9727c0
resolved "https://codeload.github.com/discord/twemoji/tar.gz/c9fb242544b5f9068221d3baadb3b5d7ec9727c0"
dependencies:
fs-extra "^8.0.1"
Expand Down Expand Up @@ -3985,9 +3984,9 @@ dir-glob@^3.0.1:
dependencies:
path-type "^4.0.0"

"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":
"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":
version "0.0.0"
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"
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"

dns-equal@^1.0.0:
version "1.0.0"
Expand Down

0 comments on commit 81c2b33

Please sign in to comment.