Skip to content

How to create a Discord bot in the Developer Portal

Create a Discord bot step by step: the application in the Developer Portal, the bot token, intents and the server invite link.

Every Discord bot is an application in the Discord Developer Portal (opens in a new tab). Before you run the bot's code on a server, you need to create it, copy the token the bot uses to log in to Discord and invite the bot to your Discord server.

Creating the application

  1. Open the Developer Portal

    Go to discord.com/developers/applications (opens in a new tab) and log in with your Discord account. The bot will belong to this account.

  2. Create the application

    Click New Application in the top right corner. Enter the bot's name in the Name field, tick the agreement to the developer terms and click Create. Discord may ask you to confirm you're not a robot.

The General Information page opens. You can change the name, description and icon here at any time. It also shows the Application ID, which some libraries need to register slash commands.

Bot token

The token is the password the bot's code uses to log in to Discord.

  1. Open the Bot tab

    In the menu on the left, click Bot. This is also where you change the bot's username and avatar shown on the server.

  2. Generate the token

    In the Token section, click Reset Token and confirm with Yes, do it!. If you have two-factor authentication on, Discord asks for a code or a security key.

  3. Copy the token

    Click Copy and store the token somewhere safe. Discord shows it only once. When you leave the page, you'll only see the Reset Token button.

Intents

Intents decide what data the bot gets from Discord. Three of them, under Privileged Gateway Intents in the Bot tab, have to be turned on by hand:

IntentWhen you need it
Presence Intentthe bot tracks members' statuses, such as who is playing what
Server Members Intentthe bot reacts to members joining and leaving or fetches the server's member list
Message Content Intentthe bot reads message content, such as prefix commands like !help

Turn on only the ones your bot uses. If the bot uses slash commands only, it usually needs none of them. After a change, click Save Changes in the bar at the bottom of the page.

A bot on more than 10,000 servers needs Discord's approval for these intents.

Inviting the bot to a server

  1. Choose the scopes

    In the menu on the left, click OAuth2 and scroll to OAuth2 URL Generator. Under Scopes, tick bot, and if the bot has slash commands, applications.commands too.

  2. Choose the permissions

    The Bot Permissions section appears below the scopes. Tick only what the bot needs. Most bots are fine with View Channels, Send Messages, Embed Links and Read Message History. A moderation bot also needs, for example, Kick Members and Ban Members.

  3. Copy the link

    Leave Guild Install in the Integration Type field and copy the link from Generated URL with the button next to it.

  4. Add the bot to a server

    Open the link in your browser. In Add to server, choose the Discord server, click Continue, check the list of permissions and confirm. The list only shows servers where you have the Manage Server permission.

The bot appears on the server's member list, but stays offline until you run its code.

Common problems

The bot is on the server but always offline

Discord shows the bot online only while its code runs with a valid token. Check that the code is running and that the token wasn't reset after you copied it.

The bot won't start with an intents error

The code asks for an intent that isn't turned on in the portal. discord.js then reports Used disallowed intents, and discord.py PrivilegedIntentsRequired. Turn on that intent in the Bot tab and click Save Changes.

My server isn't on the Add to server list

You can only add the bot to a server where you have the Manage Server permission. Ask the server owner for that permission or to add the bot using your link.

Other people can't add my bot

In the Bot tab, turn on Public Bot. When it's off, only the bot's owner can add it.