-
Notifications
You must be signed in to change notification settings - Fork 291
Creating a discord bot & getting a token
Creating a bot in discord is stupid easy. First you need to go to here and click "New Application"
Now give your bot a name and a picture, a description isn't necessary.
Click "Create Application". On the next page scroll down until you see "Create a bot user" and click that. Also click "Yes, do it!".
Now you can get your bot's token by using the "click to reveal" button in the App Bot User section.
There's your token! Now it's time to invite your bot to your server. Don't worry about the bot being up and running for this next step. Replace
YOUR_CLIENT_ID_HERE
in this URL https://discordapp.com/oauth2/authorize?&client_id=YOUR_CLIENT_ID_HERE&scope=bot&permissions=0
with the Client ID from the page above under App Details, then paste the link into your browser. It will give you a page that looks like this:
Now select your server in the dropdown, then click "Authorize".
That's it! Now you can start your bot and enjoy chatting!
IMPORTANT: you should NEVER give your bot's token to anybody you do not trust, and never EVER under any circumstances push it to a public Git repo where everyone can see it. The token gives you full access to your bot account's permissions, so if somebody gains access to it maliciously they could do any number of bad things with the bot -- this includes leaving all of its guilds (servers), spamming unfavorable links or messages in text channels, deleting messages/channels in guilds where it has moderator permissions, and other nasty stuff along those lines. Keep it a secret!
However, if your token ever does get compromised or you suspect it has been, the very first thing you should do is go to its Discord Apps page, press "click to reveal" in the App Bot User section, then click "Generate a new token?" and "Yes, do it!" in the confirmation dialog. This will give you a unique, brand-new token that you can update your bot's code with.
Afterwards, take the appropriate measures to place this new token in a secure place where it can't be leaked or compromised again. If you would like to open-source your bot's code without disclosing its token, you can store the token in a separate file (which your bot can load the token from), then add this file to .gitignore to ensure that it isn't published along with the rest of your bot.
Good luck!