How to Invite Your Bot to a Discord Server
After getting your Discord Bot up and running, you may have noticed that you're missing a step — your bot hasn't joined the server yet!
This is done by creating an "Invite Link" for your bot, which if you so choose, can be used by people to invite your bot to your server, and this guide will walk you through that exact process.
Manage Server
permission in order to add a bot to a server. If you're the owner of the server, you should automatically have that permission granted to you — if not, you may need to speak to the Admin(s) of your Discord server.To start, ensure that you've created an "Application" on the Discord Developer Portal as you will need this in order to create an invite link (as well as for the bot in general).
After you've registered an application, select it on the front page of the developer portal, and click OAuth2
on the left sidebar, found here:
From there, you'll need to grab your bot's Client ID
and note it down somewhere, as it will be part of the invite link that you create.
Bot
tab on the left sidebar, and uncheck the Public Bot
setting.Optional Step: If you want to request any users adding your bot to their server to grant the permissions your bot requires (such as the Manage Messages
permission if your bot will be deleting messages) you can encode the permissions into your invite link, the easiest way to do this is using the Discord Permissions Calculator — check all of the permissions that your bot requires (note that this will be displayed to anyone who attempts to utilize the invite link) and insert your Client ID
into the box at the bottom of the page, whilst leaving the other two boxes empty, like this:
That will generate your invite link and encode the necessary permissions into the authorization prompt for when users go to invite your bot to their server.
Note that you should ensure your bot's code checks that it has the permission to perform an elevated task (such as deleting messages) as encoding the permissions into your invite link does not guarantee that the user inviting your bot will grant the permissions you request.
Otherwise, if you do not want to request any permissions, you can use the following template to create an invite link:
``
https://discord.com/oauth2/authorize?client_id=123456789&scope=bot
``
Replace 123456789
with your bot's actual Client ID
, which will create an invite link.
Now that you have your bot's invite link, go ahead and give it a try! If you opted to encode your permissions into the URL, you'll see these included on the prompt. After you authorize the bot, it will then join the selected server! If you do not see the server you are wanting to invite your bot into, then you're most likely missing the Manage Server
permission, which is covered at the beginning of this article.
Updated on: 17/04/2021
Thank you!