Skip to content

Configuration

Julian Speckmann edited this page Jan 27, 2026 · 1 revision

Configuration

This page explains all configuration options available in the .env file.

Environment Variables

Required Variables

DISCORD_TOKEN

  • Type: String
  • Description: Your Discord bot token from the Developer Portal
  • Example: MTIzNDU2Nzg5MDEyMzQ1Njc4OQ.GhIjKl.MnOpQrStUvWxYz1234567890AbCdEfGhIjKl
  • Security: ⚠️ Keep this secret! Never commit it to version control.

CLIENT_ID

  • Type: String (Snowflake ID)
  • Description: Your Discord application ID
  • Example: 1234567890123456789
  • Where to find: Discord Developer Portal → Your App → General Information

API_TOKEN

  • Type: String
  • Description: Your SourceXchange API bearer token
  • Example: MTIzNDU2Nzg5MDEyMzQ1Njc4OQ.GhIjKl.MnOpQrStUv
  • Security: ⚠️ Keep this secret! Never commit it to version control.

PRODUCT_ID

  • Type: String
  • Description: The SourceXchange product ID to check purchases against
  • Example: 123
  • Note: Users must own this product to receive the Discord role

DISCORD_ROLE_ID

  • Type: String (Snowflake ID)
  • Description: The Discord role ID to grant/revoke based on product ownership
  • Example: 9876543210987654321
  • Where to find: Right-click role in Discord → Copy ID (requires Developer Mode)

Optional Variables

NODE_ENV

  • Type: String
  • Options: production or development
  • Default: production
  • Description: Controls logging verbosity
    • development: Verbose logging with debug information
    • production: Standard logging only

Security Best Practices

Protecting Your Tokens

  1. Never commit .env to git

    • The .env file is in .gitignore by default
    • Always use .env.example for templates
  2. Rotate tokens regularly

    • Regenerate your Discord bot token periodically
    • Update your SourceXchange API token if compromised
  3. Use environment-specific tokens

    • Use separate tokens for development and production
    • Never use production tokens in development
  4. Restrict bot permissions

    • Only grant necessary Discord permissions
    • Use role hierarchy to prevent privilege escalation

Role Hierarchy

⚠️ Important: The bot's role must be higher in the Discord role hierarchy than the role it manages.

To fix hierarchy issues:

  1. Go to Server Settings → Roles
  2. Drag your bot's role above the role specified in DISCORD_ROLE_ID
  3. Save changes

Multiple Products (Advanced)

Currently, the bot supports one product per instance. For multiple products:

Option 1: Multiple Bot Instances

Run separate bot instances with different configurations:

# Bot 1
PRODUCT_ID=123 DISCORD_ROLE_ID=9876543210987654321 npm start

# Bot 2
PRODUCT_ID=456 DISCORD_ROLE_ID=7172391210987645282 npm start

Option 2: Fork and Modify

Fork the project and modify index.js to support multiple product mappings.

Logging Configuration

Development Mode

NODE_ENV=development
  • Logs all API requests and responses
  • Shows detailed error messages
  • Displays command execution details

Production Mode

NODE_ENV=production
  • Logs only important events
  • Hides sensitive debug information
  • Optimized for performance

Troubleshooting Configuration

See the Troubleshooting page for common configuration issues.

Clone this wiki locally