Troubleshooting Guide
Detailed solutions for common issues.
Table of Contents
- Installation Issues
- Configuration Issues
- Discord Bot Issues
- API and Performance Issues
- Table Rendering Issues
- Message Processing Issues
- Development Issues
- Deployment Issues
- Getting More Help
- Preventive Measures
- Still stuck?
Installation Issues
uv command not found
Problem: When running uv sync, you get “command not found”.
Solution:
Install uv using one of these methods:
# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
# With pip
pip install uv
# With Homebrew (macOS)
brew install uv
After installation, restart your terminal or run:
source ~/.bashrc # or ~/.zshrc
Python version too old
Problem: Error about Python version requirement.
Solution:
Daia requires Python 3.12+. Check your version:
python --version
If it’s older than 3.12, install a newer version:
# macOS with Homebrew
brew install python@3.12
# Ubuntu/Debian
sudo apt update
sudo apt install python3.12
# Windows
# Download from python.org
Then ensure uv uses the correct Python:
uv python install 3.12
uv sync
Dependency installation fails
Problem: uv sync fails with dependency errors.
Solution:
- Clear cache and retry:
uv cache clean uv sync --reinstall -
Check internet connection: Ensure you can reach PyPI and GitHub.
- Update uv:
pip install --upgrade uv - Check for conflicting packages:
uv pip list
Configuration Issues
.env file not found
Problem: Bot can’t find environment variables.
Solution:
- Create .env file:
cp .env.example .env -
Verify location: The
.envfile must be in the project root directory (same level asmain.py). - Check file permissions:
ls -la .env chmod 644 .env
Invalid Discord Bot Token
Problem: “Improper token has been passed” error.
Solution:
-
Verify token format: Discord tokens look like:
MTIzNDU2Nzg5.AbCdEf.XyZ123-TokenExample - Regenerate token:
- Go to Discord Developer Portal
- Select your application
- Go to “Bot” section
- Click “Reset Token”
- Copy the new token to
.env
- Check for extra spaces:
# Wrong DISCORD_BOT_TOKEN= your_token_here # Correct DISCORD_BOT_TOKEN=your_token_here - Verify token is active: Make sure you didn’t delete the bot in the Developer Portal.
Invalid Gemini API Key
Problem: “API key not valid” error.
Solution:
- Verify key in Google AI Studio:
- Go to Google AI Studio
- Check that the key is active
- Copy it exactly (no spaces)
- Check API quota:
- Ensure you haven’t exceeded your quota
- Check usage in Google AI Studio
-
Verify key format: Gemini keys look like:
AIzaSyD1234567890abcdefghijklmnopqrstuv - Create new key if needed: If the key is invalid, create a new one in Google AI Studio.
System prompt file not found
Problem: Can’t find chat_sys_prompt.txt.
Solution:
- Create the file:
cp config/chat_sys_prompt.txt.example config/chat_sys_prompt.txt - Verify path in .env:
CHAT_SYS_PROMPT_PATH=config/chat_sys_prompt.txt - Check file exists:
ls -la config/chat_sys_prompt.txt
Discord Bot Issues
Bot doesn’t come online
Problem: Bot shows as offline in Discord.
Solution:
-
Check console for errors: Look for error messages when starting the bot.
-
Verify token: Ensure
DISCORD_BOT_TOKENis correct. -
Check internet connection: Bot needs internet to connect to Discord.
-
Verify bot wasn’t deleted: Check the Developer Portal to ensure the bot still exists.
-
Check Discord status: Visit Discord Status to see if there are outages.
Bot doesn’t respond to messages
Problem: Bot is online but doesn’t reply.
Solution:
- Enable Message Content Intent:
- Go to Discord Developer Portal
- Select your application
- Go to “Bot” section
- Scroll to “Privileged Gateway Intents”
- Enable “Message Content Intent”
- Click “Save Changes”
- Restart the bot
- Check bot permissions:
- Right-click the channel
- Go to “Edit Channel” → “Permissions”
- Find your bot
- Ensure it has:
- View Channels
- Send Messages
- Read Message History
- Verify you’re using the bot correctly:
- In allowed channels: just type
- In other channels: mention the bot (
@Daia hello) - Or send a DM
- Check console for errors: Look for error messages that might indicate the problem.
Bot can’t send messages
Problem: Bot receives messages but can’t reply.
Solution:
-
Check “Send Messages” permission: Bot needs this permission in the channel.
-
Check channel restrictions: Some channels may have restrictions on who can send messages.
-
Verify bot role: Ensure the bot’s role isn’t restricted by server settings.
-
Check rate limiting: If sending many messages quickly, Discord may rate limit the bot.
Slash commands don’t appear
Problem: /newchat command doesn’t show up.
Solution:
-
Wait for sync: Commands can take up to an hour to sync globally.
- Check bot was invited with correct scope:
- Bot needs
applications.commandsscope - Re-invite the bot with the correct URL
- Bot needs
-
Restart Discord: Sometimes Discord client needs a restart to see new commands.
- Check console for errors: Look for command registration errors.
API and Performance Issues
Rate limiting errors
Problem: “Rate limited” or “Too many requests” errors.
Solution:
- Reduce request frequency:
- Lower
HISTORY_LIMITto send fewer tokens - Add delays between messages (requires code modification)
- Lower
- Check API quotas:
- Discord: 50 requests per second
- Gemini: Check your tier in Google AI Studio
-
Implement backoff: The bot should automatically retry with exponential backoff.
- Upgrade API tier: Consider upgrading your Gemini API tier for higher limits.
Slow response times
Problem: Bot takes a long time to respond.
Solution:
- Use faster model:
CHAT_MODEL=gemini-1.5-flash - Reduce history limit:
HISTORY_LIMIT=20 # Instead of 50 -
Check network latency: Test your connection to Google’s API.
- Monitor API performance: Check Google AI Studio for API status.
Out of memory errors
Problem: Bot crashes with memory errors.
Solution:
- Reduce history limit:
HISTORY_LIMIT=30 -
Restart bot regularly: Set up a cron job or systemd service to restart periodically.
-
Check for memory leaks: Monitor memory usage over time.
- Upgrade server resources: Consider more RAM if running on limited hardware.
Table Rendering Issues
Tables not rendering as images
Problem: Tables appear as text instead of images.
Solution:
-
Check fonts downloaded: Look for “Downloading fonts…” message on first run.
-
Verify “Attach Files” permission: Bot needs this permission to send images.
-
Check console for errors: Look for PIL/Pillow errors.
- Manually download fonts:
uv run python -c "from utils.download_font import download_fonts; download_fonts()" - Verify font files exist:
ls -la assets/fonts/
Font download fails
Problem: Fonts don’t download on first run.
Solution:
-
Check internet connection: Fonts are downloaded from GitHub releases.
-
Check firewall: Ensure GitHub isn’t blocked.
- Manual download:
- Download from Noto CJK Releases
- Extract to
assets/fonts/
- Retry download: Delete
assets/fonts/and restart the bot.
CJK characters not displaying correctly
Problem: Chinese/Japanese/Korean characters look wrong.
Solution:
- Verify Noto CJK fonts installed:
ls assets/fonts/ | grep Noto -
Check font file integrity: Re-download if files are corrupted.
- Update Pillow:
uv pip install --upgrade Pillow
Message Processing Issues
Messages getting cut off
Problem: Long responses are truncated.
Solution:
This shouldn’t happen as Daia auto-chunks messages. If it does:
-
Check console for errors: Look for chunking errors.
- Verify latest version:
git pull origin main uv sync - Report the issue: Open an issue on GitHub with the message that got cut off.
Bot responds to itself
Problem: Bot replies to its own messages.
Solution:
-
Check message filtering: The bot should ignore its own messages by default.
- Verify bot ID check: In
main.py, ensure:if message.author == bot.user: return - Update to latest version: This bug should be fixed in recent versions.
Context not maintained
Problem: Bot doesn’t remember previous messages.
Solution:
- Increase history limit:
HISTORY_LIMIT=50 -
Check history fetching: Look for errors in console related to history.
-
Verify channel permissions: Bot needs “Read Message History” permission.
- Don’t use /newchat: This command clears the context.
Development Issues
Tests failing
Problem: make test or pytest fails.
Solution:
- Install dev dependencies:
uv sync --dev - Check Python version:
python --version # Should be 3.12+ - Run specific test:
uv run pytest tests/test_file.py -v - Check for import errors: Ensure all dependencies are installed.
Linting errors
Problem: make lint shows errors.
Solution:
- Auto-fix with format:
make format - Check specific errors:
uv run ruff check . - Ignore specific rules (if needed): Add to
pyproject.toml:[tool.ruff] ignore = ["E501"] # Example: ignore line length
Pre-commit hooks failing
Problem: Git commit is blocked by pre-commit.
Solution:
- Run hooks manually:
uv run pre-commit run --all-files - Auto-fix issues:
make format - Skip hooks (not recommended):
git commit --no-verify
Deployment Issues
Bot stops after closing terminal
Problem: Bot stops when you close the terminal.
Solution:
Use a process manager:
- Using screen:
screen -S daia uv run main.py # Press Ctrl+A, then D to detach # Reattach with: screen -r daia - Using tmux:
tmux new -s daia uv run main.py # Press Ctrl+B, then D to detach # Reattach with: tmux attach -t daia - Using systemd (Linux): Create
/etc/systemd/system/daia.service:[Unit] Description=Daia Discord Bot After=network.target [Service] Type=simple User=your_user WorkingDirectory=/path/to/daia ExecStart=/path/to/uv run main.py Restart=always [Install] WantedBy=multi-user.targetThen:
sudo systemctl enable daia sudo systemctl start daia
Bot crashes randomly
Problem: Bot stops unexpectedly.
Solution:
-
Check logs: Look for error messages before crash.
-
Add error handling: Ensure all async functions have try-except blocks.
-
Monitor resources: Check CPU and memory usage.
-
Set up auto-restart: Use systemd or a process manager with restart policies.
-
Update dependencies:
uv sync --upgrade
Getting More Help
If your issue isn’t covered here:
-
Check console output: Error messages often indicate the problem.
-
Search GitHub Issues: github.com/zhiro-labs/daia/issues
- Enable debug logging: Add to your code:
import logging logging.basicConfig(level=logging.DEBUG) - Ask for help:
- Provide details: When asking for help, include:
- Error messages
- Console output
- Steps to reproduce
- Your configuration (without sensitive data)
- Python and uv versions
Preventive Measures
Regular maintenance
# Update dependencies
uv sync --upgrade
# Clean cache
make clean
# Run tests
make test
# Check for issues
make ci
Monitoring
Set up monitoring for:
- Bot uptime
- API usage and costs
- Error rates
- Response times
- Memory usage
Backups
Regularly backup:
.envfile (securely)config/chat_sys_prompt.txt- Any custom modifications
Security
- Rotate API keys periodically
- Keep dependencies updated
- Monitor for security advisories
- Use environment-specific tokens
- Never commit
.envto git
Still stuck?
If you’ve tried everything and still have issues:
- Gather information:
- Full error message
- Console output
- Steps to reproduce
- Your environment (OS, Python version, etc.)
-
Open an issue: github.com/zhiro-labs/daia/issues/new
-
Be patient: Maintainers are volunteers and will help when they can.
- Consider contributing: If you solve your issue, consider submitting a PR to help others!