Setting Up Your Application

Creating your Bot Application#

You 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.

  1. Open the Discord Developer Portal.
  2. Click on the the "New Application" button.
  3. Insert the name of your Application

You should see something like this:

Setting Up a Bot Application

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:

Setting Up a Bot Application

Getting Your Token#

After creating your bot, you should be seeing something like this:

Setting Up a Bot Application

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 Application#

It'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:

DISCORD_TOKEN=
note

Make sure to open .env and not .env.example.

Copy your token and paste it after DISCORD_TOKEN=, for example:

DISCORD_TOKEN=mySecretToken
info

If you were already running your Discapp application and changed .env make sure to restart your application.