Prerequisites
Before installing WizBot, ensure you have:- Node.js (v16 or higher recommended)
- npm (comes with Node.js)
- Discord Bot Application created in the Discord Developer Portal
- Bot Token and Client ID from your Discord application
Installation Steps
Install Dependencies
Install all required npm packages:This installs:
discord.js— Discord API librarychrono-node— Natural language date parsingbetter-sqlite3— Fast SQLite databaseasync-mutex— Concurrency controldotenv— Environment variable management
Configure Bot Credentials
You have two configuration options:Or use a
Option 1: config.json (Recommended for development)
Create aconfig.json file in the root directory:Option 2: Environment Variables (Recommended for production)
Set these environment variables:.env file:.env
Environment variables take precedence over
config.json if both are present.Configuration Reference
Required Configuration
| Parameter | Environment Variable | Description |
|---|---|---|
clientId | DISCORD_CLIENT_ID | Your Discord bot’s Client ID from the Developer Portal |
token | DISCORD_TOKEN | Your Discord bot token |
Optional Configuration
| Parameter | Environment Variable | Description | Default |
|---|---|---|---|
allowedGuildIds | DISCORD_ALLOWED_GUILDS | Comma-separated list of allowed guild IDs. Leave empty to allow all guilds. | All guilds allowed |
ownerId | BOT_OWNER_ID | Your Discord user ID for receiving DM-based performance alerts | None |
| — | LOG_LEVEL | Logging verbosity: DEBUG, INFO, WARN, ERROR | INFO |
| — | LOG_TO_FILE | Enable file logging | false |
Finding Your IDs
How to get your Client ID and Token
How to get your Client ID and Token
- Go to the Discord Developer Portal
- Select your application (or create a new one)
- Navigate to the Bot section
- Token: Click “Reset Token” to view your bot token (keep this secret!)
- Client ID: Found in the General Information section
How to get your Guild ID
How to get your Guild ID
- Enable Developer Mode in Discord (User Settings > Advanced > Developer Mode)
- Right-click your server icon
- Click “Copy Server ID”
How to get your User ID
How to get your User ID
- Enable Developer Mode in Discord (User Settings > Advanced > Developer Mode)
- Right-click your username anywhere in Discord
- Click “Copy User ID”
Database Setup
WizBot uses SQLite for data persistence. The database is automatically created atdata/wizbot.db on first run.
Database Schema
The database includes tables for:- Active raids and signups
- Guild settings and permissions
- Recurring raid schedules
- User availability data
- Participation statistics
- Audit logs
The
data/ directory is gitignored by default. Make sure to back up this directory regularly!Migrating from JSON (Upgrading Users)
If you’re upgrading from an older version that used JSON files:- Reads existing JSON data files
- Imports all data into the SQLite database
- Creates backups of the original JSON files
- Preserves all raid history and statistics
Project Structure
Understanding the codebase:Testing
Run the test suite:- Time parsing and natural language dates
- State persistence and recovery
- Waitlist promotion logic
- Reaction handling
- Rate limiting
- Timezone conversion
- Permission validation
Environment Variables Reference
Complete list of all environment variables:| Variable | Type | Description | Default | Example |
|---|---|---|---|---|
DISCORD_CLIENT_ID | String | Bot client ID | Required | 123456789012345678 |
DISCORD_TOKEN | String | Bot authentication token | Required | MTIzNDU2Nzg5MDEyMzQ1Njc4.GhIjKl.MnOpQrStUvWxYz |
DISCORD_ALLOWED_GUILDS | String | Comma-separated guild IDs | All guilds | 123,456,789 |
BOT_OWNER_ID | String | User ID for DM alerts | None | 123456789012345678 |
LOG_LEVEL | String | Logging verbosity | INFO | DEBUG, INFO, WARN, ERROR |
LOG_TO_FILE | Boolean | Enable file logging | false | true, false |
Deployment
Running as a Service (Linux)
Create a systemd service file at/etc/systemd/system/wizbot.service:
Using PM2 (Cross-platform)
PM2 is a popular process manager for Node.js:Docker Deployment
Create aDockerfile:
Performance Monitoring
WizBot includes built-in performance monitoring features:DM-Based Alerts
SetBOT_OWNER_ID to receive Discord DM alerts for:
- High latency (>500ms API responses)
- DM delivery failures
- Memory usage warnings
- Circuit breaker state changes
- Daily health summary (9 AM)
Metrics Collection
WizBot tracks Prometheus-compatible metrics:- Command execution count and duration
- Reaction handler latency
- Active raid count
- Database query performance
- Memory and CPU usage
Graceful Shutdown
WizBot handlesSIGTERM and SIGINT signals gracefully:
- Saves active raid state to database
- Closes Discord connection cleanly
- Flushes database writes
- Exits with appropriate status code
Troubleshooting
Bot doesn't respond to commands
Bot doesn't respond to commands
- Verify the bot is online in your server
- Check that commands are registered with
/ping - Ensure the bot has appropriate permissions in your server
- Check console logs for errors
'Channel not configured' error
'Channel not configured' error
Use
/setchannel to configure raid signup channels, or create channels with default names:raid-signupsmuseum-signupskey-signupschallenge-signups
Time parsing isn't working
Time parsing isn't working
- Set your server’s default timezone with
/settings - Use explicit formats like “2024-12-25 19:00 EST”
- Check that chrono-node is installed:
npm list chrono-node
Database errors on startup
Database errors on startup
- Ensure the
data/directory exists and is writable - Check better-sqlite3 compilation:
npm rebuild better-sqlite3 - If migrating, run
node db/migrate.jsseparately first
High memory usage
High memory usage
- WizBot logs memory warnings automatically
- Check for very large guilds (10,000+ members)
- Consider increasing Node.js heap size:
node --max-old-space-size=4096 bot.js
Next Steps
Quickstart Guide
Learn the essential commands to start managing raids
Configuration
Customize reminders, permissions, templates, and server settings
Commands Reference
Complete documentation for all available commands
Advanced Features
Explore recurring raids, availability tracking, and analytics