Setup .env

Configuration

In the root directory of our project we need to have a plain text file that contains variables for configuring our application. We'll use the default .env filename so that when we call dotenv.config() before our app starts it will make these variables available as "environment variables" under the process.env object.

.env
TOKEN=<your discord bot token>
OWNER_ID=<your discord user id>

MYSQL_HOST=<mysql hostname>
MYSQL_PORT=<mysql port>
MYSQL_USER=<mysql username>
MYSQL_PASSWORD=<mysql password>
MYSQL_DATABASE=<mysql database

#
# Optional - If helpbot is installed
#
HELPBOT_COMMAND_PREFIX=?
HELPBOT_ADMIN_ROLE_NAME=<name of the role with super user permissions>
HELPBOT_QUESTIONS_CHANNEL_ID=<discord channel id to send helpbot questions to>

Make sure you add ".env" to your .gitignore file to prevent your token and other credentials from being exposed in your git repository remote(s).

Variables

Variable Name

Description

TOKEN

Discord bot token. This is a random string generated by authorizing the bot. Click here for more information.

OWNER_ID

Your discord user id. This is used for super user privileges for some modules.

MYSQL_HOST

MySQL hostname (most likely localhost).

MYSQL_PORT

MySQL port number (most likely 3306).

MYSQL_USER

MySQL username you setup when installing.

MYSQL_PASSWORD

MySQL password you setup when installing.

MYSQL_DATABASE

MySQL database name for your bot (you will have to create this).

HELPBOT_COMMAND_PREFIX

The first character of a message that maps to this module such as ? or >.

HELPBOT_ADMIN_ROLE_NAME

Name of the role that has administrator privileges such as managing tags, answering questions, etc.

HELPBOT_QUESTIONS_CHANNEL_ID

When questions are added or managed messages will be sent to this channel id.

Last updated