Skip to content

Create Your Discord Bot

Afonso Jorge Ramos edited this page Feb 4, 2022 · 10 revisions

Creating a Bot Account

In order to work with the Discord API in general, we must first create a Discord Bot account.

Creating a Bot account is a pretty straightforward process.

  1. Make sure you’re logged on to the Discord website.
  2. Navigate to the application page.
  3. Click on the “New Application” button.

new application

  1. Give the application a name and click “Create”.

create application

  1. Create a Bot User by navigating to the “Bot” tab and clicking “Add Bot”.
  • Click “Yes, do it!” to continue.

add bot

  1. Make sure that Public Bot is ticked if you want others to invite your bot.
  • You should also make sure that Require OAuth2 Code Grant is unchecked unless you are developing a service that needs it. If you’re unsure, then leave it unchecked.

bot

  1. Now you will need to save two important number sequences. The token in the Bot page, and the Application ID in the General Information page. These will go to your .env file, which should be similar to our example .env.

⚠ It should be worth noting that this token is essentially your bot’s password. You should never share this to someone else. In doing so, someone can log in to your bot and do malicious things, such as leaving servers, ban all members inside a server, or pinging everyone maliciously.

⚠ The possibilities are endless, so do not share this token.

⚠ If you accidentally leak your token, click the “Regenerate” button as soon as possible. This will revoke your old token and re-generates a new one, which you will need to use to login again.


Inviting Your Bot

Congratulations, you’ve created a Bot User but it’s not actually in any server.

If you want to invite your bot you must create an invite URL for it.

Automatically

The faster approach is simply replace <ApplicationID> in the following URL with your application ID.

https://discord.com/api/oauth2/authorize?client_id=<ApplicationID>&permissions=275191524416&scope=bot%20applications.commands

Otherwise, you have the manual process below. ⬇️

Manually

  1. Make sure you’re logged on to the Discord website.

  2. Navigate to the application page.

  3. Click on your bot’s page.

  4. Go to the “OAuth2” tab.

oauth2

  1. Tick the “bot” checkbox under “scopes”.

scopes

  1. Tick the permissions required that are visible below for your bot to function under “Bot Permissions”.
  • Bot owners must have 2FA enabled for certain actions and permissions when added in servers that have Server-Wide 2FA enabled. Check the 2FA support page for more information.

permissions

  1. Now the resulting URL can be used to add your bot to a server. Copy and paste the URL into your browser, choose a server to invite the bot to, and click “Authorize”.

Important! The person adding the bot needs “Manage Server” permissions to do so.


Clone this wiki locally