Building a Discord Chatbot with Python (3) - Adding Your Bot to Discord

In this article, we’ll walk through the Discord settings for your chatbot.

If you don’t already have a Discord account, start by creating one.
For a guide on account creation, check out this link.

Next, set up the Discord server where your chatbot will operate.

  1. Click the ‘+’ icon in the top-left corner.

  2. Choose “Create My Own”.

  3. Select “For me and my friends”.

  4. Enter a server name and click “Create.”

  5. Your server is now set up!

Now, let’s obtain the token required for our program.

  1. Go to the Discord Developer Portal.

  2. Click “New Application” in the top-right corner.

  3. Fill in your bot’s name, check the box, and click “Create.”

  4. Your bot is now created. Then click on “Bot” from the left menu.

  5. You’ll be taken to the bot configuration page.

  6. As we’re developing a private bot, turn off the “PUBLIC BOT” option under “Authorization Flow.”

  7. Enable the “MESSAGE CONTENT INTENT” under “Privileged Gateway Intents” to allow the bot to receive messages.

  8. Save your changes.

  9. Scroll up and click “Reset Token.”

  10. Confirm the reset since it’s not in use yet by clicking “Yes, do it!”

  11. Your token will be shown in a highlighted section. Click “Copy” to save it to your clipboard.

  12. Store the copied token in a file named .discord_token within your working directory.

Lastly, let’s get the bot into your Discord server.

  1. From the left menu, choose “OAuth2” and then select “URL Generator.” Make sure to check the “bot” option under “SCOPES.”

  2. This will reveal the “BOT PERMISSIONS” section. Define the permissions for your bot and then copy the “GENERATED URL.”

  3. Visit the copied URL and invite the bot to your newly created server.

  4. Your bot is now successfully invited!

That wraps up our article for today.
Stay tuned! In our next installment, we’ll bring our chatbot to life.

Related Content