Security help › Discord security
Keep your bot token safe
A step-by-step guide for Bot owners, with fixes for common problems.
Steps
- Never put the token in your code or in GitHub. Keep it in an environment variable or a .env file that is in .gitignore.
- Make the .env file readable only by the bot's user: chmod 600 .env (Linux).
- Never paste the token in Discord, support chats or screenshots. Nobody genuine will ask for it, including us.
- Don't run "free" bot code or game scripts you haven't read: token stealers hide in them.
- If it leaked: reset it straight away in the Discord Developer Portal → your app → Bot → Reset Token. The old one stops working at once.
- Then check the bot's servers for damage (new channels, bans, webhooks) and look for how it leaked (a commit, a log, a shared file).
What you should see
The bot starts with the new token, and the old one no longer works.
Common problems
- The bot joined servers I don't know Treat the token as stolen: reset it now, then remove the bot from those servers.
- I committed the token to GitHub Reset it first (deleting the commit isn't enough: copies already exist). GitHub also warns Discord automatically for public repos.