In this lesson, you’ll register your new bot with your guild. A bot can’t accept invites like a normal user can. Instead, you’ll add your bot using the OAuth2 protocol.
Registering Your Bot
00:00 We left off at needing to register your new bot with your new guild. So let’s take a look at how you would do that now. a bot cannot just accept an invite to a guild, the same way a human user can.
00:11 Instead, you have to manually add your bot using the OAuth2 protocol. There is a link below the video to a good explanation on the OAuth2 protocol, but the short explanation is that it is an authorization protocol where a service can grant a client application limited access based on the application’s credentials and allowed scopes.
00:31 In order to complete this, you’ll have to go back to the Discord Developer Portal, as seen here, and select the OAuth2 page from the left-hand navigation pane. From this window, you’ll be able to see the OAuth2 URL Generator, just here.
00:45 Now, what this tool does is generate an authorization URL that hits Discord’s OAuth2 API and authorizes API access using your application’s credentials. From here, you’ll want to grant your application’s bot user access to Discord APIs using your application’s OAuth2 credentials.
01:07 In order to do this, scroll down and select bot from the SCOPES options and Administrator from BOT PERMISSIONS. bot, just there, under SCOPES, and under BOT PERMISSIONS, you want to choose Administrator.
01:21 Now that you have done that, Discord has generated your application’s authorization URL with the selected scope and permissions, just here. A quick disclaimer before moving forward: while the Administrator permissions are being used in this tutorial, you should be as granular as possible when granting permissions in a real-world application. Select Copy next to the URL that was generated for you, paste it into your browser, and select your guild from the dropdown options.
01:53 Once you have chosen your guild from the dropdown menu, press Continue.
01:59 From here, you want to press Authorize
02:03 and complete the reCAPTCHA, if it comes up. It may or may not.
02:08 Authorized! You may now close window or tab.
And we’re back in the Developer Portal. Now, if you go back to your guild, you will see that the bot has been added right here.
RealPythonTutorial, and he’s got a BOT tag next to him. Or her. It.
02:27 Now, up to this point in the tutorial, what have you managed to achieve? Well, you’ve created an application that your bot will use to authenticate with the Discord APIs, a bot user that you will use to interact with other users and events in your guild.
02:43 You’ve also created a guild in which your bot user and personal user account will be active, and a Discord account with which you created everything else and that you will use to interact with your bot. Great job.
02:55 You now know how to create a bot in the Discord Developer Portal, and in doing so, have completed the first key step to creating a bot. Next up is to begin the second key step: writing code that uses Discord’s APIs and implements your bot’s behaviors.
03:11 You’ll begin to learn this key step in the next video. You’ve made it this far, so let’s get to the fun stuff.
Become a Member to join the conversation.