A full-featured Discord music bot that plays music from YouTube with interactive controls.
- Playback Controls: play, pause, resume, stop, skip, previous, restart, seek
- Queue Management: view queue, shuffle, remove, move, clear with pagination
- Playlist Support: load full YouTube playlists, supports all URL formats
- Search & Select: search YouTube and pick from top 10 results via dropdown
- Play Next: insert a song at the front of the queue
- Loop Modes: off, single track, entire queue
- Volume Control: 0-100% with persistence across bot restarts
- Interactive Player: embedded now-playing display with button controls
- Progress Tracking: real-time progress bar and time remaining
- Auto-Recovery: automatically retries playback on connection errors
- Auto-Cleanup: player embeds are cleaned up when playback stops or bot restarts
- Auto-Disconnect: leaves voice channel after 2 minutes of inactivity
- Python 3.10+
- FFmpeg (system-installed)
- Discord bot token
-
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate -
Install Python dependencies:
pip install -r requirements.txt
-
Ensure FFmpeg is installed:
# Fedora/Bazzite (usually pre-installed) ffmpeg -version # If not installed on Fedora Atomic (Bazzite): rpm-ostree install ffmpeg # Ubuntu/Debian: sudo apt install ffmpeg
-
Create a
.envfile:DISCORD_TOKEN=your_token_here -
Run the bot:
python bot.py
All commands use Discord's slash command system (type / to see them).
| Command | Description |
|---|---|
/play <query> |
Play a song or playlist from YouTube (search, URL, or playlist) |
/playnext <query> |
Add a song to play next in the queue |
/pause |
Pause the current song |
/resume |
Resume playback |
/stop |
Stop playing and clear the queue |
/skip |
Skip to the next song |
/previous |
Go back to the previous song |
/restart |
Restart the current song from the beginning |
/seek <timestamp> |
Seek to position (MM:SS or seconds) |
| Command | Description |
|---|---|
/queue |
Show the current queue |
/nowplaying |
Show the currently playing song with controls |
/refresh |
Refresh the player to show current progress |
/shuffle |
Shuffle the queue |
/move <from> <to> |
Move a song to a different position in the queue |
/remove <position> |
Remove a song from the queue |
/clear |
Clear the entire queue |
/loop <mode> |
Set loop mode (off/one/all) |
| Command | Description |
|---|---|
/join |
Join your voice channel |
/leave |
Leave the voice channel |
/volume <0-100> |
Set the volume |
/help |
Show all available commands |
When a song plays, an embedded player appears with button controls:
- Shuffle - Shuffle the queue
- Previous - Go to previous song
- Pause/Play - Toggle playback
- Skip - Skip to next song
- Loop - Cycle through loop modes
- Stop - Stop playback and clear queue
- Refresh - Update the progress display
- Go to https://discord.com/developers/applications
- Create a new application
- Go to "Bot" section and create a bot
- Copy the token
- Enable "Message Content Intent" under Privileged Gateway Intents
- Go to OAuth2 > URL Generator
- Select scopes:
bot,applications.commands - Select permissions:
Connect,Speak,Send Messages,Embed Links,Manage Messages - Use the generated URL to invite the bot to your server