Prerequisites
Before you begin, make sure you have:- Python 3.8 or higher installed
- FFmpeg installed on your system
- A Discord account
- Basic familiarity with command line interfaces
Setup steps
Install dependencies
Install the required Python packages:Install FFmpeg (required for audio processing):Ubuntu/Debian:macOS:Windows:
Download from ffmpeg.org and add to your PATH.
Download from ffmpeg.org and add to your PATH.
Create a Discord bot
Follow these steps to create your Discord bot:
- Go to the Discord Developer Portal
- Click “New Application” and give it a name
- Navigate to the “Bot” section in the left sidebar
- Click “Add Bot” and confirm
- Under the bot’s username, click “Reset Token” and copy the token (you’ll need this next)
- Enable the following Privileged Gateway Intents:
- Presence Intent
- Message Content Intent
Get a YouTube API key
The bot uses the YouTube Data API v3 for searching videos:
- Go to the Google Cloud Console
- Create a new project or select an existing one
- Enable the “YouTube Data API v3”
- Go to “Credentials” and create an API key
- Copy the API key (you’ll need it next)
Configure environment variables
Create a Add your API credentials to the Replace
.env file in the project root directory:.env file:your_youtube_api_key_here and your_discord_bot_token_here with your actual credentials from the previous steps.The bot will automatically create a
music/ directory for caching downloaded songs when it first runs.Invite the bot to your server
Generate an invite link for your bot:
- In the Discord Developer Portal, go to “OAuth2” → “URL Generator”
- Select the following scopes:
botapplications.commands
- Select the following bot permissions:
- Connect
- Speak
- Use Voice Activity
- Send Messages
- Read Message History
- Copy the generated URL and open it in your browser
- Select the server where you want to add the bot and authorize
Test your first command
Join a voice channel in your Discord server and try playing a song:The bot will:
- Search YouTube for the query
- Download the audio (first time only)
- Join your voice channel
- Start playing the song
The first time you play a song, it will take a few seconds to download. Subsequent plays of the same song will be instant thanks to caching.
What’s next?
Now that your bot is running, explore more features:All commands
Learn about
!skip, !leave, !ping, and moreConfiguration
Customize bot prefix, inactivity timeout, and other settings
Troubleshooting
Common issues and how to resolve them
Architecture
Learn about the bot’s internal architecture
Quick command reference
Here are the essential commands to get you started:| Command | Description | Example |
|---|---|---|
!play <query> | Play a song by name or URL | !play bohemian rhapsody |
!skip | Skip the current song | !skip |
!leave | Disconnect and clear queue | !leave |
!ping | Check voice connection latency | !ping |
!clearcache | Clear cached songs for your server | !clearcache |
