What is MusicBot?
MusicBot connects to your Discord voice channels and plays audio from YouTube videos. Simply provide a song name or YouTube URL, and the bot will download, cache, and stream the audio to your voice channel. The bot is designed for multi-server environments with guild-specific queue management, automatic caching, and intelligent inactivity handling.Key features
YouTube integration
Search for songs by name or use direct YouTube URLs. The bot uses the YouTube Data API v3 for intelligent search results.
Queue management
Add multiple songs to a queue. Each Discord server has its own independent queue and playback state.
Smart caching
Downloaded songs are cached per server to reduce bandwidth and improve playback speed for repeated requests.
Auto-disconnect
The bot automatically leaves voice channels after 5 minutes of inactivity to free up resources.
Use cases
Community music sessionsLet your community members queue up their favorite songs and enjoy music together in voice channels. Background music
Provide ambient music for gaming sessions, study groups, or casual hangouts. Personal DJ
Quickly play music on demand without leaving Discord or switching apps.
How it works
MusicBot uses several key technologies:- discord.py - Connects to Discord and handles voice channel operations
- yt-dlp - Downloads and extracts audio from YouTube videos
- FFmpeg - Processes and streams audio to Discord voice channels
- YouTube Data API v3 - Searches for videos based on user queries
Each Discord server gets its own playback state, queue, and cache directory. This ensures that multiple servers can use the bot simultaneously without conflicts.
Architecture highlights
The bot implements aGuildPlayerState class that encapsulates all playback-related state for each Discord server:
- Manage multiple servers simultaneously
- Maintain separate queues for each server
- Handle server-specific caching and cleanup
- Track inactivity independently per server
Next steps
Quickstart
Get your bot running in under 10 minutes
Commands
Learn all available bot commands
