Common Issues
Missing Dependencies
Problem
Bot fails to start withModuleNotFoundError:
Solution
Install all required dependencies:API Key Errors
Missing DISCORD_BOT_TOKEN
Error message (bot.py:103-105):- Create a
.envfile in the bot directory:
- Add your Discord bot token:
- Get your Discord bot token from:
- Discord Developer Portal
- Navigate to your application → Bot → Token
Missing YOUTUBE_API_KEY
Error message (bot.py:99-101):-
Get a YouTube Data API v3 key:
- Visit Google Cloud Console
- Create a project
- Enable YouTube Data API v3
- Create credentials (API key)
-
Add to
.envfile:
!play song name) requires it.
Invalid Discord Token
Error message (bot.py:755-756):- Regenerate your token in the Discord Developer Portal
- Ensure no extra spaces or quotes in
.envfile - Token should be a long string without spaces
Permission Errors
Cannot Join Voice Channel
Error message (bot.py:253-257):-
Check bot permissions in Discord:
Connect- Required to join voice channelsSpeak- Required to play audioUse Voice Activity- Recommended
-
Verify channel-specific permissions:
- Right-click voice channel → Edit Channel → Permissions
- Ensure bot role has voice permissions
- Re-invite bot with correct permissions:
36703232 includes:
- Connect
- Speak
- Send Messages
- Read Message History
File Permission Errors
Error message:- Check directory permissions:
- Fix permissions:
- Ensure bot process has write access to working directory
FFmpeg Not Found
Problem
Error when playing audio:Solution
Ubuntu/Debian:- Download from ffmpeg.org
- Extract to
C:\ffmpeg - Add
C:\ffmpeg\binto system PATH
YouTube Download Errors
yt_dlp.utils.DownloadError
Error message (bot.py:403-406):-
Region-locked video
- Video not available in bot’s region
- No direct solution (use VPN for bot)
-
Private/deleted video
- Video removed or set to private
- Try different video
-
Age-restricted content
- yt-dlp cannot access without authentication
- Avoid age-restricted videos
-
Live streams
- Bot configured with
noplaylist: True(bot.py:75) - May not support live content
- Bot configured with
- Check if video is accessible in browser
- Try different search terms
- Use direct URL instead of search
- Check yt-dlp logs:
HTTP Error 429 (Too Many Requests)
Error message:- YouTube rate limiting detected
- Wait 10-30 minutes before retrying
- Use cache to reduce downloads (automatic)
- Consider rotating IP addresses for heavy usage
Network Timeout
Error message (bot.py:154-156):- Check internet connection
- Increase timeout (bot.py:139):
- Check if YouTube is accessible:
Voice Connection Issues
Bot Joins But No Audio
Symptoms:- Bot shows as connected
- “Now playing” message sent
- No audio output
- Check voice client status:
- Verify FFmpeg installation (see FFmpeg section)
- Check file exists (bot.py:611-624):
- Reconnect bot:
Bot Disconnects Unexpectedly
Possible causes:-
Inactivity timeout (bot.py:25, 701-741)
- Default: 300 seconds (5 minutes)
- Expected behavior when queue is empty
- Check logs:
-
Voice connection lost
- Network issues
- Discord server issues
- Bot will log:
voice_client is not valid or not connected
-
Manual kick from voice channel
- User action
- No error, bot clears queue
- Adjust inactivity timeout:
- Add songs to queue to keep bot active
- Check Discord API status: status.discord.com
Already Connected to Different Channel
Error message (bot.py:238-240):- Bot can only be in one voice channel per guild
- Options:
- Have requester join bot’s current channel
- Use
!leavethen!playfrom new channel - Bot will not auto-move between channels
File Path and Caching Issues
Downloaded File Not Found
Error message (bot.py:363-365):-
FFmpeg conversion failed
- MP3 conversion incomplete
- Check FFmpeg logs
-
Disk space full
- Check available space:
-
File path mismatch
- yt-dlp output format doesn’t match expected
- Check logs for actual filename
- Verify yt-dlp output template (bot.py:326):
- Check
music/<guild_id>/directory contents:
- Enable verbose yt-dlp logging:
Cache Directory Issues
Problem: Cache not being used or cleared unexpectedly Solutions:- Verify cache structure (bot.py:281-282):
- Check cache hit logs (bot.py:315-316):
-
Cache is cleared on:
!leavecommand (bot.py:462-476)!clearcachecommand (bot.py:514-545)
-
Prevent accidental cache deletion:
- Don’t manually delete
music/directory while bot is running - Use
!clearcachefor controlled cleanup
- Don’t manually delete
Logging System
Configuration
The bot uses Python’s standard logging module (bot.py:82-90):Log Levels
CRITICAL - Fatal errors, bot cannot continue:Enabling Debug Logging
Modify logging level (bot.py:85):Logging to File
Change handler (bot.py:86-87):Reading Logs
Real-time monitoring:Advanced Debugging
Voice Client State
Add debug logging in commands:Check Guild State
The__repr__ method (bot.py:42-45) provides useful debug output:
Network Diagnostics
Test YouTube API connectivity:yt-dlp Version Issues
yt-dlp frequently updates to handle YouTube changes:Getting Help
If issues persist:- Check logs for detailed error messages
- Enable DEBUG logging for more information
- Verify all dependencies are installed and up-to-date
- Test with direct YouTube URLs before search queries
- Review recent code changes if bot was recently modified
