Guide
Keep your Discord bot token safe
Never put the token in your code; use an encrypted secret.
- In the Discord developer portal, open your app, then Bot, then Reset Token, and copy it.
- In your bot's Secrets tab, add DISCORD_TOKEN, paste the token and press Save secrets. It is encrypted and is never shown again, not even to you.
- In your code, replace the token text with
os.environ["DISCORD_TOKEN"](Python),process.env.DISCORD_TOKEN(Node.js) orSystem.getenv("DISCORD_TOKEN")(Java), and remove it from any file you upload. - If a token was ever shared or uploaded by mistake, reset it in the portal and save the new one: the old one stops working at once.
Download project never includes secrets, so you can share your code safely.
Still stuck? Log in and ask support, or check the service status. New here? See bot hosting plans from $0.70 a month.
More Discord bot guides
Host a Discord bot 24/7 (Python, Node.js or Java)From a bot on your computer to a bot that never goes offline.Host a discord.js (Node.js) botNode.js 22 with your package.json, online 24/7.Host a Java bot (JDA or Discord4J)Upload a runnable .jar, we run it on Java 21.Upload a multi-file bot (cogs, folders)Projects with cogs, config files and folders work as they are.My Discord bot is offline or keeps crashingRead the reason, fix it, deploy again.Host a music or voice botFFmpeg and Opus are added for you.