Keeping your bot safe
Your token
- Keep it in an environment variable or a file only your bot's user can read
- Never commit it, log it or show it in a screenshot
- Never ship it inside an app or a web page, anyone could pull it out
- If it leaks, make a new one in Settings → Bots. The old one stops working at once.
Messages are untrusted
- Never run message text or command options as a shell command, code or SQL, and don't build file paths from them
- For commands like
!kickor/kick, check the roles of whoever asked, not just your bot's permissions - Only answer the commands you expect, and ignore other bots
Ask for less
Ask for only the permissions your bot needs. Administrator gives it everything.
Your server
- Run the bot as its own user, not root
- Keep the system and your runtime (Node.js, Python or Go) up to date
- Use HTTPS and never turn off certificate checks
- Respect
429andRetry-After