Environment variables & secrets
DANGER
Never commit your bot token to GitHub. A leaked token lets anyone control your bot. If it leaks, reset it in the Discord Developer Portal immediately.
Option A — panel variables (recommended)
Panel → Startup → Variables → Add variable:
DISCORD_TOKEN = your-token-hereRead it in code:
js
// Node.js
const token = process.env.DISCORD_TOKEN;python
# Python
import os
token = os.environ["DISCORD_TOKEN"]Option B — a .env file
If your code uses dotenv, create .env via the file manager:
DISCORD_TOKEN=your-tokenMake the project private and the file readable only by the server user. Panel variables are safer because they survive reinstalls.
Rotate a leaked secret
- Discord Developer Portal → your app → Bot → Reset Token.
- Update the variable in the panel.
- Restart the bot.
Common variables
| Name | Purpose |
|---|---|
DISCORD_TOKEN | Bot login token |
CLIENT_ID | Application ID (slash command registration) |
GUILD_ID | Test guild for instant command sync |
MONGO_URI | Database connection string |
NODE_ENV | production |