Skip to main content
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 when bot.py starts up.
Your bot token is equivalent to a password. Never share it, commit it to version control, or paste it in a public channel. Store it exclusively in a .env file that is listed in .gitignore. If a token is ever exposed, immediately regenerate it in the Developer Portal.

Creating a Discord Application

1

Open the Developer Portal

Navigate to https://discord.com/developers/applications and sign in with your Discord account.
2

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.
3

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.
4

Copy your bot token

Under the Token section, click Reset Token, confirm the action, then copy the token that appears. This is your BOT_TOKEN.Paste it into a .env file in the project root:
.env
The bot loads this value at startup via python-dotenv:
bot.py
5

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:
bot.py
Without this toggle enabled in the portal, Nextcord will not receive message content events even if the intent is declared in code.

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.

Generating an Invite URL

1

Open the OAuth2 URL Generator

In the Developer Portal, navigate to OAuth2 → URL Generator in the left sidebar.
2

Select scopes

Under Scopes, check both:
  • bot
  • applications.commands
The applications.commands scope is required for Discord to register and display the slash commands that the bot syncs via bot.sync_application_commands().
3

Select bot permissions

The Bot Permissions panel appears once bot is checked. Enable:
  • Connect
  • Speak
  • Send Messages
  • Embed Links
  • Read Message History
4

Copy and open the generated URL

Copy the URL at the bottom of the page, paste it into a browser, select the server you want to invite the bot to, and click Authorise.
Create a dedicated Discord server purely for development and testing. This gives you a safe environment to invite the bot, trigger commands, and observe its behaviour without affecting a live community server.

Running the Bot

With Lavalink running (see Lavalink Setup) and the .env file in place, start the bot:

What happens at startup

The on_ready event fires once the bot has authenticated with Discord’s gateway. It performs three tasks in sequence:
bot.py
  1. Connects to Lavalink — creates a wavelink.Node pointed at http://127.0.0.1:2333 using the password defined in application.yml (youshallnotpass).
  2. Registers the node pool — wavelink.Pool.connect makes the node available for all subsequent voice connections.
  3. Syncs slash commands — bot.sync_application_commands() registers all @bot.slash_command decorators 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

Lavalink Setup

Run the audio server your bot connects to during startup.

Environment Variables

Confirm every value the bot expects from your .env file.

Quickstart

Use the setup steps to bring the bot up locally.

Configuration

Compare the bot, Lavalink, and permission settings in one place.