Creating a discord bot looks like it can be a difficult task from an outside view. I mean, creating a bot to do all these functions for your server? Sounds time-consuming right? But when you mix Discords API and python3, this process has never been more simple. I have gone ahead and created a skeleton version of the bot so you can easily follow along. You can grab it from the Requirements section.
Getting Started On The Front End:
– Your first step to creating a discord bot should be creating the application on discord’s website. This is where you will control the initial settings, invitations, etc. For this, you want to head over to Discord’s website. Once here, you need to get all logged in, and head to “Applications”. This is where all your discord applications will be, as the name suggests. You should see the “New Application” button towards the right hand of your screen (Figure 1). As you guessed it, click here to create your brand new application (Figure 2).
– Once here, make sure to enable the bot function (found under Settings > Bot), this will ensure your bot can be interacted with (Figure 3). You will also want to adjust any settings you see fit for your bot.
– Your last step is to now invite the bot to your server. To do this, grab this URL: “https://discordapp.com/oauth2/authorize?&client_id=INSERT_TOKEN_HERE&scope=bot&permissions=0”, grab your token (Settings > Bot > Token). Delete the string: “INSERT_TOKEN_HERE”, and add your token in its spot (Figure 4). Visit the URL and it should give you the option to choose which server to add the bot to. Once you complete these steps, you can now continue to work on the back-end of the bot.
Moving To The Back End:
– Now that your application is set up, settings are configured, dependencies are installed, it is time to connect your application to your python program. On your workstation, go ahead and open “Discord_Bot_Skeleton.py” in any editor.
– In the code, you will see a variable called “TOKEN”, as the name implies, this is where you drop your bot’s token (Figure 5). This will connect your program to your bot so it can receive commands, functions, etc. Once you drop your token, your bot should be able to connect to discord’s end, and function however you tell it to.
Side Note: Make sure to delete the space in TOKEN = ‘ ‘ before adding your token.
1. Visit Discord’s Dev Website
2. Log in, head to Applications > New Applications, and create a new application
3. Enable bot, (Settings > Bot) and adjust settings
4. Copy token, and combine it with this URL: https://discordapp.com/oauth2/authorize?&client_id=INSERT_TOKEN_HERE&scope=bot&permissions=0 || Insert Token in INSERT_TOKEN_HERE
5. Open Discord_Bot_Skeleton.py in text editor of your choice. Add your token where requested (TOKEN = ‘ ‘)
6. Open your CLI, run ‘python3 Discord_Bot_Skeleton.py’
7. Ensure print statement writes in your terminal, and ensure bot comes online in your server (Figure 6).