1. Making a Bot Account (Discord)#

Choose Social Media Platform: Reddit | Discord | Bluesky

In using this textbook, you will have opportunities to create and run social media bots. Here we will run through how to create a Discord account and set it up for running your own bots.

While we have made a fake version of Discord for you to test all the code in this book, we highly encourage you to make a Discord bot account and try it out for real!

1.1. Sign up for Discord#

https://discord.com/register

We suggest making a new, separate Discord account, just for making Discord bots, since you don’t want to accidentally get your main Discord account banned or labeled as a bot. Also we suggest using a different password than you use for other accounts, since you might accidentally share it with your code.

Note: If you want to make a new account and you already have one, you may need to sign out from your current account, use a different email address, or use a different web browser (e.g., Mozilla, Google Chrome, Microsoft Edge, Safari).

1.2. Create your own Discord Server#

It is easiest to test your bot by creating your own discord server.

Screenshot of the discord interface with the "+" add a server button highlighted, and then in the menu under "Create a server", the "Create my own" button is highlighted.

Fig. 1.1 Create a Discord server#

1.3. Create a Discord “Application”#

Note: Instructions are based on the official instructions here: https://discord.com/developers/docs/getting-started

In order for your bot to run, you must create a Discord “Application.” Go to the Discord Developer Portal and click “New Application”:

Screenshot of the discord developer panel, with the "application" tab open, and the "New Application" button circled.

Fig. 1.2 Create a new application in the developer portal.#

Make up a name for your app and press the “Create” button:

Screenshot of the discord create app dialog, with the name for the app being "soc_media_bot_teaching_demo"

Fig. 1.3 Make up a name for your application (the name of your bot).#

1.4. Get Discord Token#

In order to make your bot work, you’ll need to create a special password for your bot to use, which is called a “token.” Reset your token and save it somewhere (e.g., email it to yourself). You’ll need it later to let your bot log in.

Screenshot of discord developer application screen with Bot tab selected and the "Reset Token" button circled.

Fig. 1.4 Reset your token and save it somewhere.#

1.6. Add app to a Discord Server#

To add your bot to your own discord server, open a new browser tab and copy the link in to the url bar. Then you will have an option to add your bot to any servers you own.

A new browser tab is opened with the Generated URL copied into it. This opens a site saying "An external application wants to access your Discord account." The "Add To Server" section is highlighted with a Discord server selected, and the "Continue" button is circled.

Fig. 1.8 Add your bot to one of your servers.#

Note: After adding app to server, there is a confirmation page about the permissions. “Authorize” your bot.

1.7. Get Channel Id Number#

One additional piece of information you might need for your bot is the channel ID for a channel in a discord server. In order to get a channel ID, open your settings menu.

The discord profile part of the screen with the username, and mute options. The gear options button is circled.

Fig. 1.9 Open your settings menu.#

Then enable developer mode in the advanced settings.

In the discord settings change, the advanced tab is selected. In the advanced tab "Developer mode" is circled to turn on.

Fig. 1.10 Enable developer mode.#

Once developer mode is on, you can get a channel ID by right-clicking on a channel.

A screenshot of a discord server page. One of the channels has been right-clicked on, and the very bottom of the right-click menu is the "Copy Channel ID" option, which is circled.

Fig. 1.11 Copy the channel ID by right clicking.#

Save the channel ID somewhere so you can have your bot reference it later (e.g., post to that channel).

1.8. Test your tokens#

Now that you have your token, and other info, you can test out your code in chapter 2.3.8 (Demo: Try Running the Discord Bot!). You can try running the code and replacing the fake discord token and channel ids with the ones from your account, and see if you can use the code to make an actual post to your account.

1.9. Understand Discord Rules for Bots#

Before you try doing anything too creative with Discord bots, make sure you look over the Discord Developer Policy, that way you don’t get yourself banned.