Setting Up Your Application
#
Creating your Bot ApplicationYou already configured your Discapp project and almost everything is ready, but for running a Discord bot you first have to configure your project in Discord.
- Open the Discord Developer Portal.
- Click on the the "New Application" button.
- Insert the name of your Application
You should see something like this:
Make sure to give your bot a good name, optionally you can also enter a description and avatar for you bot.
Once you've configured your application, click on the "Bot" tab in the left pane. Next click on the "Add Bot" button on the right:
#
Getting Your TokenAfter creating your bot, you should be seeing something like this:
You can get your Discord token by clicking on "Click to Reveal Token" or by hitting the "Copy" button.
danger
Make sure to keep your token in secret, as if anyone with this token can pretend to be your bot.
If you think you token has been leaked, regenerate a new one and update the references to your token.
#
Setting The Token on a Discapp ApplicationIt's a good pratice to keep your tokens and other secrets (not only Discord related) in your .env
files. This way your token is not hardcoded in your code.
If you've setted up your Discapp application using create-discapp
as in the Getting Started chapter, we already configured a .env
for you.
Copy your token as in the Creating Your Token section, open the .env
file in path/to/your/app
you should see something like this:
note
Make sure to open .env
and not .env.example
.
Copy your token and paste it after DISCORD_TOKEN=
, for example:
info
If you were already running your Discapp application and changed .env
make sure to restart your application.