7.8 KiB
Discord Jukebox Bot - Troubleshooting Guide
This guide helps you resolve common issues with the Discord Jukebox Bot.
Note: For more detailed diagnostics, run the bot in debug mode:
./jukebox-bot -debug
ormake run-debug
Important: The bot now streams real audio to Discord voice channels!
Common Errors
"Invalid Form Body" / "Value is not snowflake"
Error Message
Error starting bot: error creating command 'jukebox': HTTP 400 Bad Request,
{"message": "Invalid Form Body", "code": 50035, "errors": {"guild_id": {"_errors":
[{"code": "NUMBER_TYPE_COERCE", "message": "Value \"guild_id=1234567890123456\" is not snowflake."}]}}}
Cause
This happens when your Guild ID contains extra text or isn't in the correct format. Discord expects Guild IDs to be numeric snowflakes (just numbers).
Solution
- Check your
.env
file for theJUKEBOX_DISCORD_GUILD_ID
variable - Make sure it contains ONLY the numeric Guild ID, for example:
JUKEBOX_DISCORD_GUILD_ID=1234567890123456789
- Remove any extra text, spaces, quotes, or the variable name itself from the value
- If you copied the line with
JUKEBOX_DISCORD_GUILD_ID=
, make sure you didn't accidentally include the line twice
Environment Variables Not Loading
Symptoms
- Bot reports "configuration is required" or "X is required" at startup
- Commands don't work properly
- Bot cannot connect to Discord or your Subsonic server
Solutions
-
Check your .env file location
- Make sure the .env file is in the same directory as the bot executable
- Run
make debug
to check if the .env file is detected
-
Check .env file format
- Ensure each variable is on its own line
- No spaces around the equal sign:
JUKEBOX_DISCORD_TOKEN=yourtoken
(correct) - Not:
JUKEBOX_DISCORD_TOKEN = yourtoken
(incorrect) - All variables must have the
JUKEBOX_
prefix
-
Check variable names
- Copy exact variable names from the
.env.example
file - Common issues: typos, missing prefix, wrong capitalization
- Copy exact variable names from the
-
Use direct environment variables
- If .env isn't working, set variables directly in your shell:
export JUKEBOX_DISCORD_TOKEN=yourtoken export JUKEBOX_SUBSONIC_SERVER=https://yourserver.com # etc...
- If .env isn't working, set variables directly in your shell:
Discord Connection Issues
Symptoms
- "Error creating Discord session" message
- "Error opening connection" message
- Bot starts but doesn't appear online in Discord
Solutions
-
Check your Discord bot token
- Verify the token in the Discord Developer Portal
- Generate a new token if necessary
- Make sure you're using the bot token, not the client secret
-
Check bot permissions
- The bot needs proper OAuth2 scopes and permissions
- Required scopes:
bot
,applications.commands
- Required permissions: Connect, Speak, Send Messages, Use Slash Commands
-
Verify slash commands
- Commands may take up to an hour to register globally
- Try using guild-specific commands for faster testing
- Check if you provided the correct Guild ID
Subsonic Connection Issues
Symptoms
- "subsonic server is required" error
- "Error getting random songs" message
- Bot connects to Discord but doesn't play music
Solutions
-
Check your Subsonic credentials
- Verify the server URL, username, and password
- Try logging in through a web browser to confirm credentials
- Server URL should include
http://
orhttps://
prefix
-
Check Subsonic API compatibility
- Ensure your server supports the Subsonic API
- Try setting an older API version (e.g.,
JUKEBOX_SUBSONIC_VERSION=1.13.0
) - Some Subsonic-compatible servers only implement part of the API
-
Network connectivity
- Ensure the server is reachable from where the bot is running
- Check firewall settings that might block connectivity
- Try accessing the server from the same machine using a browser
Guild ID Issues
Symptoms
- "Invalid Form Body" error when starting the bot
- "Value is not snowflake" error message
- Bot starts but commands don't register
Solutions
-
Correct Guild ID Format
- Guild ID should be only numbers with no other characters
- Correct:
JUKEBOX_DISCORD_GUILD_ID=123456789012345678
- Incorrect:
JUKEBOX_DISCORD_GUILD_ID=guild_id=123456789012345678
- Incorrect:
JUKEBOX_DISCORD_GUILD_ID="123456789012345678"
-
Check for Duplicates
- Make sure the Guild ID variable isn't defined twice in your
.env
file - Sometimes copy-pasting causes duplicated variables
- Make sure the Guild ID variable isn't defined twice in your
-
Get a Fresh Guild ID
- Enable Developer Mode in Discord (Settings > Advanced)
- Right-click your server and select "Copy ID"
- Use this exact ID in your configuration
Voice Connection Issues
Symptoms
- Bot responds to commands but doesn't join voice channel
- "Error joining voice channel" message
- Bot joins voice channel but doesn't play audio
Solutions
-
Check Discord permissions
- Bot needs "Connect" and "Speak" permissions in the voice channel
- Try giving the bot Administrator permission temporarily to test
-
User in voice channel
- The user must be in a voice channel when using
/jukebox play
- The bot will join the user's current channel
- The user must be in a voice channel when using
-
Guild ID configuration
- Make sure your
JUKEBOX_DISCORD_GUILD_ID
is correct - You can get the Guild ID by enabling Developer Mode in Discord, then right-clicking the server and selecting "Copy ID"
- Make sure your
Audio Playback Issues
Symptoms
- Bot joins voice channel successfully but no sound plays
- "Error creating encoding session" message in logs
- Songs appear to be playing (bot shows "Now playing") but no audio
Solutions
-
Check Subsonic streaming capabilities
- Verify your Subsonic server allows streaming
- Test streaming directly in your browser by visiting the stream URL (visible in debug logs)
- Some Subsonic servers require additional authentication for streaming
-
Check audio format compatibility
- The bot now converts audio to Opus format required by Discord
- Some audio formats might not be compatible with the encoder
- If specific songs don't play, try different ones to rule out format issues
-
Network issues
- Ensure your Subsonic server is accessible from where the bot is running
- Check firewall settings that might be blocking the audio stream
- Audio streaming requires stable, low-latency connectivity
-
Discord limitations
- Discord has bandwidth limits that might affect audio quality
- Try a different voice region if audio is choppy or not playing
- The default bitrate (96kbps) should work on most Discord servers
Debugging
For better debugging information:
-
Run the bot in debug mode
./jukebox-bot -debug
or
make run-debug
-
Use the debug command for environment checks
make debug
-
Check log output
- Look for error messages in the console
- The debug mode shows detailed API requests and responses
- Audio playback simulation will show progress updates
-
Try running directly
- Run the bot directly with Go:
cd discord-jukebox-bot go run ./cmd/bot -debug
-
Audio debugging
- In debug mode, the bot will print the exact stream URL being used
- Copy this URL and try opening it in a browser to test if streaming works
- Look for "Audio streaming in progress" messages showing actual bytes sent
- If you see "error creating encoding session", the audio format may be incompatible
Still Having Issues?
If you're still experiencing problems:
-
Open an issue on the GitHub repository with:
- The exact error message
- Your environment (OS, Go version)
- Steps to reproduce the issue
- Output from
make debug
-
Make sure to remove any sensitive information (tokens, passwords) before sharing logs.