Skip to main content

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

  1. Click the New Application button in the top right
  2. Enter a name for your bot (e.g., “MusicBot”)
  3. Accept the Discord Developer Terms of Service
  4. Click Create

Step 3: Configure bot settings

  1. In the left sidebar, click Bot
  2. Click Add Bot to convert your application into a bot
  3. Confirm by clicking Yes, do it!
You can customize your bot’s username and avatar in the bot settings page.

Get bot token

Your bot token is required for the DISCORD_BOT_TOKEN environment variable.

Copy the token

  1. In the Bot section, find the Token field
  2. Click Reset Token (if this is your first time)
  3. Click Copy to copy the token to your clipboard
Never share your bot token publicly! Anyone with your token can control your bot. If your token is exposed, regenerate it immediately from the Developer Portal.
Add this token to your .env file:
.env
DISCORD_BOT_TOKEN=your_copied_token_here

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:
PermissionPurpose
Read Messages/View ChannelsSee channels and commands
Send MessagesRespond to commands and send notifications
ConnectJoin voice channels
SpeakPlay audio in voice channels
Use Voice ActivityTransmit audio without push-to-talk
Create an invite link to add your bot to Discord servers.

Step 1: Configure OAuth2 settings

  1. In the left sidebar, click OAuth2URL Generator
  2. Under Scopes, select:
    • bot
  3. Under Bot Permissions, select:
    • Read Messages/View Channels
    • Send Messages
    • Connect
    • Speak
    • Use Voice Activity

Step 2: Copy invite URL

  1. Scroll down to the Generated URL section
  2. Click Copy to copy the invite link
  3. Paste this URL in your browser to invite the bot to your server
You need Manage Server permission on a Discord server to add bots.

Invite bot to server

  1. Open the generated invite URL in your browser
  2. Select the server you want to add the bot to
  3. Review the requested permissions
  4. Click Authorize
  5. Complete the CAPTCHA verification
Your bot should now appear in your server’s member list as offline (until you run it).

Bot configuration summary

The bot is configured in bot.py (lines 19-26) with:
bot.py
intents = discord.Intents.default()
intents.typing = False
intents.presences = True
intents.message_content = True

bot = commands.Bot(command_prefix='!', intents=intents)
Key settings:
  • 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:
  1. Run the bot: python bot.py
  2. Check your Discord server - the bot should appear online
  3. Look for this log message:
    INFO:discord: Bot connected as YourBotName (ID: 123456789)
    INFO:discord: Bot is ready and listening on X server(s).
    
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:
  1. Complete the configuration setup with environment variables
  2. Start using the bot with commands
  3. Learn about playing music

Build docs developers (and LLMs) love