Description
Enhance the error handling when the DISCORD_TOKEN environment variable is missing or invalid.
Current Behavior
The bot currently raises a generic RuntimeError with minimal guidance.
Desired Behavior
Provide clear, actionable error messages that guide users to:
- Check if
.env file exists
- Verify token format
- Provide setup instructions
Task
- Modify
bot.py error handling section
- Add specific error messages for different failure cases
- Include helpful links or instructions
Why this is good for beginners
- Teaches proper error handling patterns
- Improves user experience
- Simple string/validation logic
- No external dependencies
Files to modify
Example improved error message
if not TOKEN:
raise RuntimeError(
"DISCORD_TOKEN not found!\n"
"1. Copy .env.example to .env\n"
"2. Replace YOUR_BOT_TOKEN_HERE with your bot token\n"
"3. Get a token from https://discord.com/developers/applications"
)
Acceptance Criteria
Description
Enhance the error handling when the
DISCORD_TOKENenvironment variable is missing or invalid.Current Behavior
The bot currently raises a generic
RuntimeErrorwith minimal guidance.Desired Behavior
Provide clear, actionable error messages that guide users to:
.envfile existsTask
bot.pyerror handling sectionWhy this is good for beginners
Files to modify
bot.py(lines 11-13)Example improved error message
Acceptance Criteria