Before the bot can join a voice channel and play music, you need a registered Discord application with a bot token, the correct gateway intents enabled, and an invite link scoped to the right permissions. This guide walks through each step in the Discord Developer Portal and then shows exactly what happens whenDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/DJERLO/Simple-Discord-Music-Bot-Using-Nextcord/llms.txt
Use this file to discover all available pages before exploring further.
bot.py starts up.
Creating a Discord Application
Open the Developer Portal
Navigate to https://discord.com/developers/applications and sign in with your Discord account.
Create a new application
Click New Application in the top-right corner. Give it a name — this becomes the default bot username — then click Create.
Add a bot user
In the left sidebar, open the Bot tab. Click Add Bot and confirm. Discord creates a bot user attached to your application.
Copy your bot token
Under the Token section, click Reset Token, confirm the action, then copy the token that appears. This is your The bot loads this value at startup via
BOT_TOKEN.Paste it into a .env file in the project root:.env
python-dotenv:bot.py
Enable Message Content Intent
Still on the Bot tab, scroll down to Privileged Gateway Intents. Enable Message Content Intent.The bot code explicitly requests this intent:Without this toggle enabled in the portal, Nextcord will not receive message content events even if the intent is declared in code.
bot.py
Setting Bot Permissions
When inviting the bot to a server you must grant it the permissions it needs to function. The table below lists every required permission and why it is needed.| Permission | Category | Reason |
|---|---|---|
| Connect | Voice | Join voice channels to stream audio |
| Speak | Voice | Transmit audio through the voice connection |
| Send Messages | Text | Post now-playing embeds and command responses |
| Embed Links | Text | Render rich embeds with artwork and track details |
| Read Message History | Text | Allow the bot to edit its own persistent player message |
Generating an Invite URL
Open the OAuth2 URL Generator
In the Developer Portal, navigate to OAuth2 → URL Generator in the left sidebar.
Select scopes
Under Scopes, check both:
botapplications.commands
applications.commands scope is required for Discord to register and display the slash commands that the bot syncs via bot.sync_application_commands().Select bot permissions
The Bot Permissions panel appears once
bot is checked. Enable:- Connect
- Speak
- Send Messages
- Embed Links
- Read Message History
Running the Bot
With Lavalink running (see Lavalink Setup) and the.env file in place, start the bot:
What happens at startup
Theon_ready event fires once the bot has authenticated with Discord’s gateway. It performs three tasks in sequence:
bot.py
- Connects to Lavalink — creates a
wavelink.Nodepointed athttp://127.0.0.1:2333using the password defined inapplication.yml(youshallnotpass). - Registers the node pool —
wavelink.Pool.connectmakes the node available for all subsequent voice connections. - Syncs slash commands —
bot.sync_application_commands()registers all@bot.slash_commanddecorators with Discord’s API.
Global slash command registration can take up to an hour to propagate to all servers. During development, commands usually appear much faster — typically within a few minutes of the bot connecting.
Configuration Reference
| Value | Where | Purpose |
|---|---|---|
BOT_TOKEN | .env | Authenticates the bot with Discord’s gateway |
http://127.0.0.1:2333 | bot.py on_ready | Lavalink node URI |
youshallnotpass | bot.py on_ready | Lavalink node password (must match application.yml) |