Environment variables and tokens

RunUpdated

Each server has a set of variables in the panel. The template reads them on every start, so restart the bot after you change one.

Variables on every plan

  • Bot token (BOT_TOKEN) holds your Discord bot token. Your code reads it from the environment. It isn't written into the startup command, and the start scripts don't print it.
  • Main file (MAIN_FILE) is the entry file on Node (default index.js) and Python (default main.py).
  • Jar file (JAR_FILE) is the jar JDA runs (default bot.jar).
  • Build on start (BUILD_ON_START), JDA only: at 1, it runs the Gradle shadowJar build before start.

Extra variables for GitHub deploy

  • Git repository (GIT_REPO) is an optional clone URL. Leave it empty to upload files yourself.
  • Git branch (GIT_BRANCH) is the branch to clone and update from. The default is main.
  • Git token (GIT_TOKEN) is available on paid plans for private repositories. Free supports public repositories only.
  • Auto update (AUTO_UPDATE) is 0 or 1. At 1, the first start clones the repository, and every later start fetches the branch and resets tracked files to it.

Reading the token in code

discord.js
client.login(process.env.BOT_TOKEN);
discord.py
client.run(os.environ["BOT_TOKEN"])
JDA
JDABuilder.createLight(System.getenv("BOT_TOKEN"))
Keep the token out of git

Don't commit the token or put it in a config file you upload. If you use a .env file locally, add it to .gitignore and leave it off the server. The variable already does that job.

If a token leaks

  1. Reset the token in the Discord developer portal right away. The old one stops working at once.
  2. Paste the new token into Bot token.
  3. Restart the bot.

The git token

Leave Git token empty for a public repository. For a private one, use a token that can only read that repository, such as a fine-grained GitHub token with read-only access to contents. The template hands it to git through a helper, so it never appears in the clone URL. If the console says git clone failed or git update failed, check the token and the branch name.

Note

You can turn on git for a server that already has files. Set the variables and restart. Nothing is deleted: files with the same names as files in the repository move to a pre-git-backup- folder, and files git doesn't track, such as a local database, are left alone.

For a full walkthrough, including how to get backed-up files back and how to reinstall with git connected, read deploy discord.js.

Still stuck? Contact support