To run and develop the bot locally, you need to create a Discord bot application and add it to your own "staging" server.
Follow the Discord.js guides:
The bot needs the Message Content Intent and Server Members Intent permissions turned on.
The bot needs applications.commands and bot scopes.
Generate an invite link for the bot and enter it into any browser.
Note
Bot permissions involving threads/mentions/messages should suffice, but you can give it Administrator since it's just a test bot in your own testing Discord server.
Add these to your .env file:
DISCORD_TOKEN= # Bot token (production)
DISCORD_DEBUG_TOKEN= # Bot token (local development)
DISCORD_CLUSTER_STAGING_ID= # Server ID (production)
DISCORD_DEBUG_CLUSTER_STAGING_ID= # Server ID (local development)Note
For local development, you can set the DEBUG variants to the same values as the production ones.
Found in your bot's page within the Discord Developer Portal:
Right-click your staging Discord server and select Copy Server ID:




