Create bot application
To use MusicBot, you need to create a Discord bot application and obtain a bot token.Step 1: Access Discord Developer Portal
Navigate to the Discord Developer Portal and sign in with your Discord account.Step 2: Create new application
- Click the New Application button in the top right
- Enter a name for your bot (e.g., “MusicBot”)
- Accept the Discord Developer Terms of Service
- Click Create
Step 3: Configure bot settings
- In the left sidebar, click Bot
- Click Add Bot to convert your application into a bot
- Confirm by clicking Yes, do it!
Get bot token
Your bot token is required for theDISCORD_BOT_TOKEN environment variable.
Copy the token
- In the Bot section, find the Token field
- Click Reset Token (if this is your first time)
- Click Copy to copy the token to your clipboard
.env file:
.env
Configure bot permissions
MusicBot requires specific permissions to function properly in voice channels.Required intents
In the Bot section, scroll down to Privileged Gateway Intents and enable:- Message Content Intent: Required for reading command messages (the bot uses
!prefix commands)
The bot uses default intents plus message content access. Presence updates are enabled for showing the bot’s status.
Required permissions
When inviting the bot to your server, ensure it has these permissions:| Permission | Purpose |
|---|---|
| Read Messages/View Channels | See channels and commands |
| Send Messages | Respond to commands and send notifications |
| Connect | Join voice channels |
| Speak | Play audio in voice channels |
| Use Voice Activity | Transmit audio without push-to-talk |
Generate invite link
Create an invite link to add your bot to Discord servers.Step 1: Configure OAuth2 settings
- In the left sidebar, click OAuth2 → URL Generator
- Under Scopes, select:
bot
- Under Bot Permissions, select:
- Read Messages/View Channels
- Send Messages
- Connect
- Speak
- Use Voice Activity
Step 2: Copy invite URL
- Scroll down to the Generated URL section
- Click Copy to copy the invite link
- Paste this URL in your browser to invite the bot to your server
Invite bot to server
- Open the generated invite URL in your browser
- Select the server you want to add the bot to
- Review the requested permissions
- Click Authorize
- Complete the CAPTCHA verification
Bot configuration summary
The bot is configured inbot.py (lines 19-26) with:
bot.py
- Command prefix:
!(all commands start with!) - Message content intent: Enabled for command processing
- Presence updates: Enabled to show current song as bot status
Verify bot connection
After completing setup and configuration:- Run the bot:
python bot.py - Check your Discord server - the bot should appear online
- Look for this log message:
If the bot appears online and you see the connection logs, your Discord bot is configured correctly!
Next steps
With your Discord bot created and configured:- Complete the configuration setup with environment variables
- Start using the bot with commands
- Learn about playing music
