Skip to main content
RaidBot can be configured using either a config.json file or environment variables. Environment variables take precedence over config file values.

Environment Variables

The bot uses environment variables for core configuration. Create a .env file in the root directory or set these variables in your hosting environment.
DISCORD_CLIENT_ID
string
required
Your Discord application client ID. Find this in the Discord Developer Portal under your application’s OAuth2 settings.
DISCORD_TOKEN
string
required
Your Discord bot token. Keep this secret and never commit it to version control.
Never share your bot token. If exposed, regenerate it immediately in the Discord Developer Portal.
DISCORD_ALLOWED_GUILDS
string
Comma-separated list of guild (server) IDs where the bot is allowed to operate. Leave empty to allow all guilds.Example:
DISCORD_ALLOWED_GUILDS="123456789012345678,987654321098765432"
BOT_OWNER_ID
string
Discord user ID of the bot owner. Required for receiving DM-based performance alerts and admin commands.
RESTRICTED_MESSAGE
string
default:"This bot is not authorized for this server."
Custom message shown when the bot is used in an unauthorized server (when DISCORD_ALLOWED_GUILDS is set).
LOG_LEVEL
string
default:"INFO"
Logging verbosity level. Options: DEBUG, INFO, WARN, ERROR
LOG_TO_FILE
boolean
default:"false"
Enable file-based logging in addition to console output.
LOG_COLORIZE
boolean
default:"true"
Enable colored console output for logs. Set to false to disable colors (useful for log aggregation systems).

Configuration File

Alternatively, create a config.json file in the root directory:
{
  "clientId": "YOUR_CLIENT_ID",
  "token": "YOUR_BOT_TOKEN",
  "allowedGuildIds": ["GUILD_ID_1", "GUILD_ID_2"],
  "ownerId": "YOUR_USER_ID",
  "restrictedMessage": "This bot is not authorized for this server."
}
Environment variables take precedence over config.json values. This allows you to use the config file for defaults and override specific values with environment variables in production.

Configuration Loading

The bot loads configuration in this order (utils/config.js:14-57):
  1. Load .env file if present
  2. Read config.json if it exists
  3. Override with environment variables
  4. Validate required fields (clientId and token)
If required configuration is missing, the bot will exit with an error message.

Finding Your IDs

  1. Go to the Discord Developer Portal
  2. Select your application
  3. Navigate to OAuth2General
  4. Copy the Client ID
  1. Go to the Discord Developer Portal
  2. Select your application
  3. Navigate to Bot
  4. Click Reset Token (or Copy if you haven’t reset it yet)
  5. Save this token securely
  1. Enable Developer Mode in Discord (User Settings → Advanced → Developer Mode)
  2. Right-click on a server icon
  3. Click Copy Server ID
  1. Enable Developer Mode in Discord (User Settings → Advanced → Developer Mode)
  2. Right-click on your username
  3. Click Copy User ID

Starting the Bot

Once configured, start the bot:
node bot.js
You should see startup logs indicating successful configuration loading and connection to Discord.

Next Steps

After initial setup, configure:

Build docs developers (and LLMs) love