A Discord music bot built with Python, discord.py, and yt-dlp for reliable YouTube streaming.
- 🎵 Spotify Integration - Search and play Spotify tracks via YouTube
- 🎥 YouTube Streaming - Direct YouTube URL support
- 🔍 Smart Search - Find songs by name, artist, or URL
- 📋 Queue Management - Add, skip, stop, and view queue
- 🧪 Testing Commands - Test YouTube streaming directly
- ⚡ Reliable Streaming - Uses yt-dlp for stable audio streaming
pip install -r requirements.txtCopy env_example.txt to .env and fill in your credentials:
cp env_example.txt .envEdit .env:
DISCORD_TOKEN=your_discord_bot_token_here
SPOTIFY_CLIENT_ID=your_spotify_client_id_here
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret_here
- Go to Discord Developer Portal
- Create a new application
- Go to "Bot" section and create a bot
- Copy the bot token to your
.envfile - Enable "Message Content Intent" and "Server Members Intent"
- Invite bot to your server with these permissions:
- Send Messages
- Use Slash Commands
- Connect
- Speak
- Use Voice Activity
- Go to Spotify Developer Dashboard
- Create a new app
- Copy Client ID and Client Secret to your
.envfile
python music_bot.py/play <query>- Play a song from Spotify or YouTube/skip- Skip the current song/stop- Stop playing and clear queue/queue- Show the current queue/testyt <url>- Test YouTube streaming with a direct URL/sync- Sync slash commands (owner only)
/play Never Gonna Give You Up- Search and play a song/play https://open.spotify.com/track/...- Play a Spotify track/play https://youtube.com/watch?v=...- Play a YouTube video/testyt https://youtube.com/watch?v=dQw4w9WgXcQ- Test YouTube streaming
- Add multiple songs to queue
- Skip current song
- View queue status
- Automatic next song playback
- Search Spotify tracks
- Play Spotify songs via YouTube
- Display Spotify metadata
- Link back to Spotify
- Direct YouTube URL support
- High-quality audio streaming
- Reliable yt-dlp backend
- Error handling and fallbacks
- Test YouTube URLs directly
- Debug streaming issues
- Verify bot functionality
-
Bot not responding to commands
- Check if bot has proper permissions
- Ensure slash commands are synced with
/sync - Verify bot token is correct
-
Voice connection issues
- Make sure bot has "Connect" and "Speak" permissions
- Check if voice channel is available
- Verify bot is not already connected elsewhere
-
YouTube streaming errors
- yt-dlp should handle most YouTube changes automatically
- Check internet connection
- Try different video URLs
-
Spotify integration not working
- Verify Spotify credentials in
.env - Check if Spotify API is working
- Ensure track is available on YouTube
- Verify Spotify credentials in
The bot provides detailed logging:
- Search results
- Streaming status
- Error messages
- Command usage
Check console output for debugging information.
discord.py- Discord API wrapperyt-dlp- YouTube audio extractionspotipy- Spotify API wrapperpython-dotenv- Environment variable managementyoutube-search-python- YouTube searchPyNaCl- Voice encryption
This project is for educational purposes. Please respect YouTube's Terms of Service and Discord's API Terms of Service.