Creating a Bot Account
Before you start using discord.js, you need to decide which type of bot you want to make. You have the option to create a self-bot or a "real" bot.
1) Choosing a Bot
Self Bots (User Bots)
A self-bot runs on your account. This can be useful for creating custom commands for yourself. A self-bot comes with multiple restrictions:
- Self-bots cannot respond to the messages of other users
- Self-bots cannot collect information about invites sent in chat channels - this is known as "invite scraping".
- Self-bots are subject to the same Terms of Service as any other account.
Additionally, self bots cannot use some features of discord.js due to limitations set by the Discord API, e.g. bulk-deleting messages.
"Real" Bots
Real bots are known as bot accounts. They are allowed to interact with other users and generally have access to more features of discord.js and the Discord API. They are not allowed to scrape for invites and are subject to the same Terms of Service as any other account.
Bot accounts should be used for any serious development of bots. They can be identified by their BOT badge next to the username:
2) Getting an Account Token
To have access to your bot account, you need access to its token. Both user and bot accounts have tokens. You can think of your bot's token as its password, so you should keep the token private.
Once you have obtained an account token following the steps below, make sure you keep it safe. If other people get this token, they have full access to your bot account. If you are using a self-bot, they have full access to your user account.
Tokens for Self Bots (User Bots)
- Open the official Discord Client or the Web Application
- Press
CTRL + SHIFT + I
(or⌘ + OPTION + I
on macOS). The developer console should appear (similar to the one in the gif below) - Click on the Application tab
- Under the Storage section, expand Local Storage
- Click on https://discordapp.com under Local Storage
- In the table that appears, find the value for
token
- copy this value
After following these steps, you should have copied your token.
In the gif, above the token that was copied
is MjYxNjAyNDA3MzI1MjM3MjQ5.Cz3Yyg.k3UasL4Ay2QLTlV3D4jkvnrzA04
(don't worry, this token won't work 😛).
If there are any quotation marks at the start or end of this token, remove them. Keep this token safe and secure.
Tokens for "Real" Bots:
Creating your Bot Application
An application on Discord can be used to create a bot, so you need to make an application first:
- Login to the browser version of Discord
- Go to the Developer Applications section
- Click New App
- Give your application a name, e.g. Dice Bot
- Give your application a description, e.g. Rolls a dice
- If you want to, give your application an icon (this will be the avatar of the bot)
- Click Create App
Getting the Application's Token
- Click Create a Bot User then Yes, do it!
- Click click to reveal next to the Token field
- Copy the token that is present
You may also choose to uncheck the Public Bot checkbox if you don't want your bot being added by users other than yourself. You can modify this at any time.
Next
After you have your bot token, take a look at how to install discord.js