Skip to content

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.

Panel → Startup → Variables → Add variable:

DISCORD_TOKEN = your-token-here

Read 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-token

Make the project private and the file readable only by the server user. Panel variables are safer because they survive reinstalls.

Rotate a leaked secret ​

  1. Discord Developer Portal → your app → Bot → Reset Token.
  2. Update the variable in the panel.
  3. Restart the bot.

Common variables ​

NamePurpose
DISCORD_TOKENBot login token
CLIENT_IDApplication ID (slash command registration)
GUILD_IDTest guild for instant command sync
MONGO_URIDatabase connection string
NODE_ENVproduction

Hosting for Minecraft, Discord bots, Lavalink, VPS and databases.