Environment Variables Reference
Relevant source files
The following files were used as context for generating this wiki page:
TrackerBot utilizes environment variables to manage configuration for its two primary services: the Discord bot (bot.js) and the bug intake web server (webserver.js). These variables control critical functionality including authentication tokens, Discord role and channel IDs, and GitHub repository routing for issue reports.
Centralized validation is performed at startup to ensure all required parameters are present before the services initialize. New required variables must be added to the validation logic in src/config/env.js, documented in the README.md, and added to the .env.example template.
Sources: AGENTS.md:1-25, README.md:30-55
Configuration Architecture
The project employs a structured approach to environment variable management, separating the Discord bot requirements from the web server requirements.
Validation Flow
The system uses a "fail-fast" approach. The bot.js entry point calls ensureEnvVars() before any client initialization. Similarly, webserver.js executes validateWebEnv() immediately after loading dotenv.
The diagram shows the validation logic that prevents the application from running with an incomplete configuration.
Sources: bot.js:1-12, webserver.js:14-27, src/config/env.js:1-18
Discord Bot Configuration
These variables are required for the operation of the Discord bot, including automated role assignment, welcome messages, and administrative command permissions.
| Variable | Description | Required? | Default / Note |
|---|---|---|---|
DISCORD_TOKEN | Authentication token for the Discord bot. | Yes | Obtained from Discord Developer Portal. |
WELCOME_CHANNEL_ID | ID of the channel where welcome messages are posted. | Yes | Used in memberHandlers.js. |
AUTO_ROLE_ID_1 | First role ID assigned to new members. | Yes | Part of the join role set. |
AUTO_ROLE_ID_2 | Second role ID assigned to new members. | Yes | Part of the join role set. |
AUTO_ROLE_ID_3 | Third role ID assigned to new members. | Yes | Part of the join role set. |
AUTO_ROLE_ID_4 | Fourth role ID assigned to new members. | Yes | Target for /put-member-role. |
PANEL_ADMIN_ROLE_ID | Role ID permitted to use the /put-member-role command. | Yes | Checked in slashHandlers.js. |
ADMIN_ROLE_ID | Comma-separated IDs for administrative roles. | Yes | Grants access to /wipe and /nuke. |
ALLOWED_COMMAND_ROLE_IDS | Roles permitted to use general member commands. | No | Defaults to 1433391726051197020. |
HONEYPOT_CHANNEL_ID | ID of the hidden anti-spam honeypot channel. | No | If missing, honeypot logic is a no-op. |
Sources: src/config/env.js:1-10, src/config/constants.js:3-18, README.md:33-46, src/handlers/honeypotHandler.js:8-10
Web Server and GitHub Configuration
The web server facilitates the intake of data and bug reports, routing them to specific GitHub repositories via the GitHub API.
The diagram illustrates how environment variables provide the necessary credentials and destination paths for the GitHub integration.
Sources: webserver.js:16-51
Variable Definitions
GITHUB_TOKEN: A Personal Access Token (PAT) withreposcope orissues:writegranular access.REPO_DEV: The repository path (e.g.,org/repo) for website-related bug reports.REPO_DATA_REPORT: The repository path for Tarkov data-specific issues.ALLOWED_ORIGINS: A comma-separated list of origins (e.g.,https://tarkovtracker.org) used for CORS-like origin checking in the report routes.PORT: The port the Express server listens on. Defaults to3000.
Sources: webserver.js:16-75, README.md:47-50
Implementation Details
Centralized Validation Helper
The bot service uses src/config/env.js to define and verify required keys.
// src/config/env.js
const requiredEnvVars = [
"DISCORD_TOKEN",
"WELCOME_CHANNEL_ID",
"AUTO_ROLE_ID_1",
"AUTO_ROLE_ID_2",
"AUTO_ROLE_ID_3",
"AUTO_ROLE_ID_4",
"PANEL_ADMIN_ROLE_ID",
"ADMIN_ROLE_ID"
];
export function getRequiredEnv(name) {
const value = process.env[name];
if (!value) {
throw new Error(`Missing required environment variable: ${name}`);
}
return value;
}
Sources: src/config/env.js:1-18
Derived Constants
In src/config/constants.js, environment variables are parsed into data structures (like Set) for efficient lookups during interaction handling.
// src/config/constants.js
export const adminRoles = new Set(
(process.env.ADMIN_ROLE_ID || "")
.split(",")
.map(id => id.trim())
.filter(Boolean)
);
Sources: src/config/constants.js:12-18
Summary
TrackerBot relies on environment variables for its operational identity and security. By separating required variables (Discord authentication and role management) from optional ones (Honeypot protection and custom command roles), the architecture ensures that core services are robust while allowing for flexible deployment configurations. All variables are validated at runtime to prevent partial service failures.