How to create a Discord Bot Application

AstroGD
5 min readNov 24, 2020

Discord Bots are a simple way to enhance the user experience on your server by adding new functionality. Most of the popular bots are already hosted by their owners but what if you want to host your own bot?

Hosting your own bot does not only make your server special, you can also decide on the bots name and profile picture. Also you have full control over the bot — That’s pretty cool, isn’t it?

Discord Developer Portal

Discord Developer Applications are managed via the Discord Developer Portal. There you can find all your bots, edit them and get the credentials so that your program can log into Discord.

First we need to create an Application so lets head over to the Discord Developer Portal.

Overview page of the Discord Developer Portal (2020)

The first thing we need to do is creating a new Application. If you haven’t found it already: The button is on the top right corner of the screen (“New Application”).

Create an application popup

Enter a name for your application in the popup and press “Create”. You can change the bot’s name to a different one later.

Setting up your Application

Nice — The first step is done. Now we need to configure the Developer Application to have an actual Bot-Account connected to it. Head on over to the “Bot” Section in the right menu.

Create a bot within the application

This one is very straightforward: Click on “Add Bot” on the right to create a bot account that is connected to your application and confirm the Popup by clicking on “Yes, do it!”.

Bot specific settings

Okay — There’s your bot. Now you can edit the username and profile picture if you want to make your bot look extra fancy. You also might want to un-check the “Public Bot” Setting. If enabled everyone knowing the Client-ID (which can be found under the “General Information” Section in the right menu) can invite your bot to his server. When enabling this option you must make sure that the program you will be running is configured for use with multiple servers. You are always able to invite the bot to your server regardless of this setting — Because you are the owner.

Privileged Gateway Intents

In November 2020 Discord made severe changes to the Discord API. Some actions can only be executed if one of the currently two Gateway Intents is enabled.

Note: If your Bot is on more than 100 servers you need it to get verified before you are able to enable these intents! If your bot is in less than 100 servers everything is fine.

Carefully read the documentation or Readme.md of the program you want to run to know what you need to enable here.

If your Bot has issues regarding roles or members you may need to enable “Server Members Intent”. If your bot needs to access the current game of a user or his online status you might want to enable “Presence Intent”.

If you are not sure what you need to enable you can always contact the developer of your software.

Options to enable privileged gateway intents

NOTE: In April 2022 access to message contents will become a privileged intent as well. If your bot is below 75 servers that is not a problem, you can enable the intent and continue as normal. If your bot reaches 75 servers however, it is eligible vor verification and the message content intent will only be enabled with a valid reason after your bot gets verified. This does not include commands! Bots on 75 or more servers will need to use the new Interactions like slash commands or buttons in order to receive instructions.

Log into the bot

Congrats! You have successfully created your very own bot. Now you only need to copy your token and insert it in the config file of your program to start using it. But before that here’s an important warning:

With the token of your bot anyone can log into the bot account and do everything they want with it. It is like the admin password to your computer or the credentials to your banking account: NEVER SHARE THE TOKEN OR PUBLISH IT ONLINE! If needed you can generate a new token in the “Bot”-Section of your application to revoke current access to your bot. There have been too many incidents with shared or uploaded tokens that destroyed entire servers.

Get the bot token here

Okay enough warning: Click on “Copy” to copy the secret token right to your clipboard. You can also click to reveal it but make sure nobody is watching 😮.

Next to the Copy button is the “Regenerate”-Button. Press it to regenerate your token. All previous tokens will be revoked instantly.

Now just paste the token where it is needed inside your program and have fun with your super cool Discord bot!

Hey, Thanks for reading this post!
If you want you can check out my GitHub here or visit my Homepage here.

If you have any questions or if something I wrote is wrong or has changed I’m happy to hear from you. Just head onto my Discord or send me an email.

--

--

AstroGD

Hi! I’m Lukas, a german Software-, Backend- and Web-developer currently studying computer science in Darmstadt