How to Set Up Discord Bots: A Step-by-Step Guide
In this article
You can automate tasks, moderate content, and add music or games to your Discord server by creating and inviting a bot. To get started, you need a Discord account, a server where you have "Administrator" permissions, and a web browser to access the Discord Developer Portal.
What You'll Need
- A verified Discord account with email confirmation.
- Access to a Discord server where you hold Administrator privileges.
- A modern web browser (Chrome, Firefox, Edge, or Safari).
- A text editor (optional, if you plan to write custom code later).
Step-by-Step
- Create a New Application: Navigate to the Discord Developer Portal in your browser. Log in if prompted. Click the "New Application" button in the top right corner. Give your application a unique name that describes its purpose (e.g., "MyServerModBot") and click "Create." This step registers your bot with Discord's systems.
- Generate the Bot Token: In the left sidebar of your new application page, click on "Bot." Click the "Add Bot" button to convert the application into a bot user. Warning: Do not share your token with anyone. Click "Copy" next to the token field. Paste this into a secure location immediately, as Discord will hide it afterward. If you lose it, you must reset it.
- Configure Privileged Gateway Intents: Scroll down in the Bot settings to find "Privileged Gateway Intents." Enable "Message Content Intent" if your bot needs to read message text. Enable "Server Members Intent" if it needs to see user lists. These toggles are required for modern bots to function correctly and ensure privacy compliance.
- Invite the Bot to Your Server: Go back to the main "OAuth2 > URL Generator" tab in the sidebar. Under "Scopes," select "bot." Under "Bot Permissions," check the boxes for permissions your bot requires (e.g., "Manage Messages," "Send Messages," "Read Message History"). Copy the generated URL at the bottom and paste it into a new browser tab. Select the server you want to add the bot to and authorize the installation.
- Verify the Bot is Online: Return to your Discord client. Refresh your server list. The bot should now appear in the member list. It may be offline initially if no code is running, but it is successfully installed. To test basic functionality, try using a command provided by the bot or check its status in the server members panel.
Common Mistakes
Many users fail because they skip the permission setup or mishandle security. First, forgetting to enable "Message Content Intent" causes bots that read chat logs to stop working silently. Second, sharing your bot token publicly allows others to hijack your bot. Third, assigning excessive permissions (like "Administrator") when only specific ones are needed creates security risks. Always follow the principle of least privilege.
Tips
Use descriptive names for your applications to keep track of multiple bots. Regularly review the "Audit Log" in your server settings to monitor what the bot does. If you are coding your own bot, use environment variables to store your token rather than hardcoding it in your script. Joining the official Discord API support server can provide help with complex integration issues.
Troubleshooting
If your bot does not appear in the server, ensure you selected the correct server during the OAuth2 invitation process. Check that you are an Administrator in that server. If the bot appears but does not respond to commands, verify that the bot has the necessary permissions for the specific channel. Restart the bot application if you are running local code. If the token was compromised, go to the Developer Portal and click "Reset Token" immediately, then re-invite the bot using the new token.
Frequently Asked Questions
Can I create a bot without coding?
Yes. Many third-party services allow you to configure bots via web dashboards without writing code. However, creating a custom bot from scratch requires programming knowledge in languages like Python or JavaScript.
Is it free to make a Discord bot?
The Discord Developer Portal and API are free to use. You only incur costs if you host your bot on a paid server or use premium third-party services.
Why is my bot offline?
A bot is offline if the code running it is not executing. If you are using a pre-made bot, it might be undergoing maintenance. If you wrote the code, check your console for errors.
Do I need to pay for privileged intents?
No. Enabling intents like Message Content or Server Members is free, but it requires verification of your bot account if it joins more than 100 servers.