Complete guide for setting up HazeBot Discord bot with or without API integration.
- Prerequisites
- Choosing Your Setup Mode
- Option 1: Bot Only (No API)
- Option 2: Bot + API (With Admin Panel)
- Environment Variables
- Optional Services
- Troubleshooting
HazeBot can run in two modes:
| Mode | File | Loads APIServer Cog? | Use Case |
|---|---|---|---|
| Bot Only | Main.py |
❌ No | Testing, development, or Discord-only features |
| Bot + API | start_with_api.py |
✅ Yes | Production with web/mobile admin panel |
Key Differences:
Main.py- Automatically skips APIServer cog, no Flask/API dependencies neededstart_with_api.py- Loads APIServer as a cog, enables REST API + WebSocket
Recommended:
- Start with
Main.pyfor testing - Switch to
start_with_api.pyfor production with admin panel
- Python 3.11+ - Download
- Discord Bot Token - Get from Discord Developer Portal
- Discord Guild (Server) ID - Enable Developer Mode in Discord → Right-click server → Copy ID
- Git - For cloning the repository
- Virtual Environment - Keeps dependencies isolated
Perfect for running just the Discord bot without web interface or admin panel.
git clone https://github.com/inventory69/HazeBot.git
cd HazeBot# Linux/macOS
python3 -m venv .venv
source .venv/bin/activate
# Windows
python -m venv .venv
.venv\Scripts\activatepip install -r requirements.txtCore Dependencies:
discord.py- Discord API wrapperaiohttp- Async HTTP clientpython-dotenv- Environment variable management- See REQUIREMENTS.md for full list
- Go to Discord Developer Portal
- Click New Application → Enter name (e.g., "HazeBot")
- Go to Bot tab → Click Add Bot
- Under Token, click Reset Token → Copy it (save securely!)
- Enable these Privileged Gateway Intents:
- ✅ Server Members Intent
- ✅ Message Content Intent
- ✅ Presence Intent
- Go to OAuth2 → URL Generator
- Scopes:
bot,applications.commands - Bot Permissions:
Administrator(or customize) - Copy generated URL and invite bot to your server
- Scopes:
cp .env.example .env
nano .env # or use any text editorMinimum required variables:
# Discord Configuration
DISCORD_BOT_TOKEN=your_discord_bot_token_here
DISCORD_GUILD_ID=your_guild_id_hereOptional but recommended:
# Rocket League (for RL cog)
ROCKET_API_BASE=https://api.example.com
ROCKET_API_KEY=your_key
# Email (for ticket transcripts)
SMTP_SERVER=smtp.gmail.com
SMTP_PORT=465
SMTP_USER=your@email.com
SMTP_PASS=your_password
SUPPORT_EMAIL=support@example.com
# OpenAI (for AI changelog generation)
OPENAI_API_KEY=sk-...HazeBot uses Config.py for channel/role IDs and feature settings. Most configuration is done via .env, but you need to update IDs in Config.py:
Edit Config.py and update the PROD_IDS dictionary (lines 161-203):
PROD_IDS = {
# Role IDs
"ADMIN_ROLE_ID": 123456789, # Admin role
"MODERATOR_ROLE_ID": 987654321, # Moderator role
"NORMAL_ROLE_ID": 111222333, # Normal member role
"MEMBER_ROLE_ID": 444555666, # Member role
"CHANGELOG_ROLE_ID": 777888999, # Changelog notification role
"MEME_ROLE_ID": 123123123, # Meme notification role (optional)
# Channel IDs
"LOG_CHANNEL_ID": 111111111, # Bot logging channel
"CHANGELOG_CHANNEL_ID": 222222222, # Changelog posts
"TODO_CHANNEL_ID": 333333333, # Todo list channel
"RL_CHANNEL_ID": 444444444, # Rocket League stats
"MEME_CHANNEL_ID": 555555555, # Daily memes (optional)
"SERVER_GUIDE_CHANNEL_ID": 666666666, # Server guide (optional)
"GAMING_CHANNEL_ID": 777777777, # Gaming channel (optional)
"WELCOME_RULES_CHANNEL_ID": 888888888,# Welcome/rules channel
"WELCOME_PUBLIC_CHANNEL_ID": 999999999,# Public welcome channel
"TICKETS_CATEGORY_ID": 101010101, # Support tickets category
"TRANSCRIPT_CHANNEL_ID": 121212121, # Ticket transcripts
# Additional Configuration
"INTEREST_ROLE_IDS": [], # Interest role IDs (optional)
"INTEREST_ROLES": {}, # Interest role names (optional)
}Important Settings in Config.py:
# Lines 89-93: Bot behavior
BotName = "Haze World Bot"
CommandPrefix = "!"
PresenceUpdateInterval = 3600 # seconds between presence updates
MessageCooldown = 5 # seconds between user messages
FuzzyMatchingThreshold = 0.6 # command matching sensitivity
# Lines 481-483: Rocket League settings
RL_RANK_CHECK_INTERVAL_HOURS = 3 # How often to check ranks
RL_RANK_CACHE_TTL_SECONDS = 10500 # Cache duration
# Lines 569-595: Meme system (auto-loaded from Data/ files)
DEFAULT_MEME_SUBREDDITS = ["memes", "dankmemes", ...]
DEFAULT_MEME_LEMMY = ["196@lemmy.blahaj.zone", ...]
MEME_TEMPLATES_CACHE_DURATION = 86400 # 24 hours💡 Tips:
- Use Discord Developer Mode to copy IDs (Right-click → Copy ID)
- Most IDs can stay at defaults if you don't use that feature
- Use
TEST_IDSdictionary (lines 204-246) for test server configuration - Set
PROD_MODE=falsein.envto use TEST_IDS instead of PROD_IDS
python Main.pyYou should see:
🚀 Starting Cog loading sequence...
└─ ⏭️ Skipped: AnalyticsManager (requires API - use start_with_api.py)
└─ ✅ Loaded: CogManager
└─ ✅ Loaded: DiscordLogging
└─ ✅ Loaded: General
└─ ✅ Loaded: Moderation
... (more cogs)
🧩 All Cogs loaded: CogManager, DiscordLogging, General, ...
🔗 Synced 15 guild slash commands.
🤖 HazeWorldBot starting in PRODUCTION mode
HazeBot is online as HazeBot#1234!
Note: AnalyticsManager and APIServer are automatically skipped in bot-only mode (use start_with_api.py for full features).
In Discord:
!help - Show all commands
!ping - Test bot responsiveness
!listcogs - Show loaded cogs
!reload <cog> - Reload a cog (admin only)
✅ Bot-only setup complete! The bot is now running with all Discord features.
Includes Flask API for web/mobile admin panel with advanced management features.
Follow all steps from Option 1 above to get the base bot running.
pip install -r api_requirements.txtAdditional Dependencies:
Flask- Web frameworkFlask-CORS- Cross-origin requestsPyJWT- JWT authenticationFlask-SocketIO- Real-time WebSocket communicationfirebase-admin- Push notifications (optional)
Add to your .env file:
# ============================================================================
# API CONFIGURATION
# ============================================================================
# API Port (5070 recommended to avoid conflicts)
API_PORT=5070
# JWT Secret Key (generate with: python -c "import secrets; print(secrets.token_hex(32))")
SECRET_KEY=your-very-secret-key-change-in-production
# Admin Credentials
API_ADMIN_USER=admin
API_ADMIN_PASS=your_secure_password_here
# Additional users (optional, format: username:password,username2:password2)
API_EXTRA_USERS=moderator:pass123,user:pass456
# CORS Origins (comma-separated, for web/mobile access)
CORS_ORIGINS=https://your-domain.com,http://localhost:3000
# Discord OAuth2 (optional, for Discord login in admin panel)
DISCORD_CLIENT_ID=your_client_id
DISCORD_CLIENT_SECRET=your_client_secret
DISCORD_REDIRECT_URI=https://your-domain.com/api/discord/callback
# Firebase Cloud Messaging (optional, for push notifications)
FCM_SERVER_KEY=your_fcm_server_keyOnly needed if you want mobile push notifications in the admin panel.
- Create Firebase project at Firebase Console
- Download
firebase-credentials.jsonfrom Project Settings → Service Accounts - Place file in HazeBot root directory
- See HazeBot-Admin FIREBASE_SETUP.md for full instructions
# Add to .env (optional)
FIREBASE_CREDENTIALS=firebase-credentials.jsonpython start_with_api.pyYou should see:
🚀 Starting Cog loading sequence...
└─ ✅ Loaded: AnalyticsManager
└─ ✅ Loaded: APIServer
└─ ✅ Loaded: CogManager
└─ ✅ Loaded: DiscordLogging
... (more cogs)
🧩 All Cogs loaded: AnalyticsManager, APIServer, CogManager, ...
🔗 Synced 15 guild slash commands.
🌐 API Server: Starting Flask app on 0.0.0.0:5070
* Running on http://0.0.0.0:5070
📡 WebSocket server ready
🤖 Starting Discord bot (API will start via APIServer cog)...
HazeBot is online as HazeBot#1234!
Note: API is now loaded as a Cog (APIServer) and starts automatically with the bot.
# Test API health endpoint
curl http://localhost:5070/api/health
# Expected response:
{"status": "ok", "timestamp": "2024-12-05T10:30:00Z"}
# Test authentication
curl -X POST http://localhost:5070/api/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"your_password"}'
# Expected response:
{"token": "eyJ...", "user": "admin", "role": "admin"}To use the Flutter web/mobile interface:
Quick Links:
Quick Start:
# Clone admin panel
git clone https://github.com/inventory69/HazeBot-Admin.git
cd HazeBot-Admin
# Install Flutter dependencies
flutter pub get
# Configure API URL
cp .env.example .env
nano .env # Set API_BASE_URL=http://localhost:5070/api
# Run web interface
flutter run -d chrome
# Or build Android APK
flutter build apk --releaseFull instructions: ADMIN_PANEL_SETUP.md
✅ Bot + API setup complete! You can now manage HazeBot via web/mobile interface.
Legend:
- ✅ Required - Must be set for basic functionality
- 📱 Optional - Enables specific features
- 🌐 API Only - Only needed when running
start_with_api.py
# ============================================================================
# DISCORD CONFIGURATION ✅ (Required for both modes)
# ============================================================================
DISCORD_BOT_TOKEN=your_discord_bot_token_here
DISCORD_GUILD_ID=your_guild_id_here
# Optional: Test mode configuration (set PROD_MODE=false to use these)
TEST_DISCORD_BOT_TOKEN=your_test_bot_token
DISCORD_TEST_GUILD_ID=your_test_guild_id
DISCORD_TEST_GUILD_NAME=Test Server Name
# Production mode toggle (default: false)
PROD_MODE=true
# ============================================================================
# ANALYTICS 📱 (Optional - set backend type)
# ============================================================================
ANALYTICS_BACKEND=sqlite # Options: sqlite (default), json
TIMEZONE=Europe/Berlin # Timezone for analytics
# ============================================================================
# ROCKET LEAGUE 📱 (Optional - for RL stats tracking)
# ============================================================================
ROCKET_API_BASE=https://api.tracker.gg
ROCKET_API_KEY=your_rocket_api_key_here
FLARESOLVERR_URL=http://localhost:8191 # For bypassing Cloudflare
# ============================================================================
# EMAIL / SMTP 📱 (Optional - for ticket transcripts)
# ============================================================================
SMTP_SERVER=smtp.gmail.com
SMTP_PORT=465
SMTP_USER=your_email@gmail.com
SMTP_PASS=your_app_password_here
SUPPORT_EMAIL=support@yourdomain.com
# ============================================================================
# OPENAI 📱 (Optional - for AI changelog generation)
# ============================================================================
OPENAI_API_KEY=sk-proj-...
# ============================================================================
# IMGFLIP 📱 (Optional - for meme template generation)
# ============================================================================
IMGFLIP_USERNAME=your_imgflip_username
IMGFLIP_PASSWORD=your_imgflip_password
# ============================================================================
# API CONFIGURATION 🌐 (Only needed with start_with_api.py)
# ============================================================================
API_PORT=5070
# JWT Secret Key (generate with: python -c "import secrets; print(secrets.token_hex(32))")
SECRET_KEY=change-this-to-a-random-string-use-secrets-token-hex-32
# Admin Credentials
API_ADMIN_USER=admin
API_ADMIN_PASS=secure_password_change_in_production
# Additional users (format: username:password,username2:password2)
API_EXTRA_USERS=moderator:pass123,user:pass456
# CORS Origins (comma-separated, for web/mobile access)
CORS_ORIGINS=https://your-domain.com,http://localhost:3000,http://192.168.1.100:3000
# Discord OAuth2 (optional, for Discord login in admin panel)
DISCORD_CLIENT_ID=your_client_id
DISCORD_CLIENT_SECRET=your_client_secret
DISCORD_REDIRECT_URI=https://your-domain.com/api/discord/callback
# Discord Role IDs (for API access control)
ADMIN_ROLE_ID=123456789
MODERATOR_ROLE_ID=987654321
LOOTLING_ROLE_ID=111222333 # Regular user role
# ============================================================================
# FIREBASE 🌐 (Optional - for mobile push notifications with API)
# ============================================================================
FIREBASE_CREDENTIALS=firebase-credentials.json
FCM_SERVER_KEY=your_fcm_server_keyPriority Setup:
- Minimum (Bot only):
DISCORD_BOT_TOKEN,DISCORD_GUILD_ID - With API: Add
API_PORT,SECRET_KEY,API_ADMIN_USER,API_ADMIN_PASS - Full features: Add optional services as needed (RL, OpenAI, SMTP, etc.)
What it does: Automatically formats changelogs with GPT-4 Turbo
Setup:
- Get API key from OpenAI Platform
- Add to
.env:OPENAI_API_KEY=sk-... - Use
!changelogcommand with AI formatting
Cost: ~$0.01 per changelog (uses GPT-4 Turbo)
What it does: Bypasses Cloudflare protection for RL API scraping
Setup:
# Docker (recommended)
docker run -d \
--name=flaresolverr \
-p 8191:8191 \
ghcr.io/flaresolverr/flaresolverr:latest
# Add to .env
FLARESOLVERR_URL=http://localhost:8191Alternative: Use official Rocket League API if available
What it does: Sends ticket transcripts via email when closed
Setup for Gmail:
- Enable 2FA on Google Account
- Generate App Password: Account → Security → 2-Step Verification → App Passwords
- Add to
.env:
SMTP_SERVER=smtp.gmail.com
SMTP_PORT=465
SMTP_USER=your.email@gmail.com
SMTP_PASS=your_app_password_here
SUPPORT_EMAIL=support@yourdomain.comError: discord.errors.LoginFailure: Improper token has been passed
- ✅ Check
DISCORD_BOT_TOKENin.envis correct - ✅ Token should start with
MTk...or similar - ✅ Regenerate token in Discord Developer Portal if needed
Error: Guild not found
- ✅ Verify
DISCORD_GUILD_IDmatches your server - ✅ Enable Developer Mode in Discord → Right-click server → Copy ID
- ✅ Make sure bot is invited to the server
Check loaded cogs:
# In bot logs, look for:
└─ ✅ Loaded: DailyMeme
└─ ❌ Failed to load RocketLeague: No module named 'rlapi'
└─ ⏸️ Skipped (disabled): TestCogCommon reasons:
- Missing dependencies (install with
pip install -r requirements.txt) - Cog is persistently disabled (use
!enablecog CogNameto re-enable) - Python syntax error in cog file
Manage cogs:
!listcogs # Show all cogs and their status
!reload CogName # Reload a specific cog
!disablecog CogName # Persistently disable a cog
!enablecog CogName # Re-enable a disabled cog
Note: In bot-only mode (Main.py), APIServer cog is automatically skipped.
Error: Connection refused when accessing API
- ✅ Make sure you started with
python start_with_api.py(notpython Main.py) - ✅ Look for
✅ Loaded: APIServerin startup logs - ✅ Check firewall allows port 5070
- ✅ Verify
API_PORTin.envmatches (default: 5070)
Error: 401 Unauthorized when accessing endpoints
- ✅ Obtain JWT token via
/api/auth/loginendpoint - ✅ Include token in header:
Authorization: Bearer <token> - ✅ Check username/password in
.env(API_ADMIN_USER, API_ADMIN_PASS)
From mobile device:
- Use your PC's local IP (not localhost)
- Find IP:
ip addr show(Linux) oripconfig(Windows) - Example:
http://192.168.1.100:5070/api - Make sure
CORS_ORIGINSin.envincludes your access URL
WebSocket not connecting:
- ✅ Use
wss://for HTTPS orws://for HTTP - ✅ Include JWT token in connection auth object
- ✅ Check browser console for specific error messages
Bot can't send messages / create channels:
- ✅ Bot needs
Administratorpermission (or specific permissions) - ✅ Re-invite bot with correct permissions from OAuth2 URL
- 📖 Features Guide - Complete command reference
- 🏗️ Architecture - Understanding the cog system
- 📱 Admin Panel Setup - Web/mobile interface
- 🚀 Deployment Guide - Production deployment
- 🤝 Contributing - Development guidelines
| File/Folder | Purpose |
|---|---|
Main.py |
Start bot only (no API) - skips APIServer cog |
start_with_api.py |
Start bot + API server - loads APIServer cog |
Config.py |
Bot configuration (IDs, settings, feature toggles) |
.env |
Secrets & environment variables (tokens, passwords) |
Cogs/ |
Modular bot features (22 cogs) |
api/ |
Flask API for admin panel (REST + WebSocket) |
Data/ |
Production data (JSON/SQLite files) |
TestData/ |
Test mode data (when PROD_MODE=false) |
Utils/ |
Helper functions and utilities |
| Lines | Section | Description |
|---|---|---|
| 25-46 | Environment | PROD_MODE, BOT_TOKEN, GUILD_ID, DATA_DIR |
| 89-93 | Bot Behavior | BotName, CommandPrefix, MessageCooldown |
| 161-203 | PROD_IDS | Production server channel/role IDs |
| 204-246 | TEST_IDS | Test server channel/role IDs |
| 254-286 | ID Exports | Exports correct IDs based on PROD_MODE |
| 294-318 | Slash Commands | List of commands with slash (/) support |
| 392-426 | Server Guide | Server guide configuration |
| 431-476 | Welcome System | Rules, messages, button replies |
| 477-564 | Rocket League | Rank tracking, emojis, congrats messages |
| 565-604 | Meme System | Subreddits, Lemmy communities, templates |
1. Required (.env)
DISCORD_BOT_TOKEN- Bot authenticationDISCORD_GUILD_ID- Server ID
2. Required (Config.py PROD_IDS)
- All channel IDs and role IDs for your server
3. Optional Features
- Enable in
.envas needed (RL, OpenAI, SMTP, etc.) - Configure in
Config.pyfor feature-specific settings
Need help? Open an issue on GitHub or check the documentation!
Made with 💖 for The Chillventory 🌿