Skip to main content

Discord Bot Integration

SnailyCAD now has a bot which can be used to call emergency, tow and taxi services.

Requirements​

All the items listed below are required to use the bot.

Installation​

1. Cloning the GitHub repository​

warning

Warning: Do not install the bot in the root folder. Install it in your Documents folder on Windows or home folder on Linux.

To fix this, run the following command:

Windows

cd Documents

Linux

cd /home/$(whoami)

Firstly, we need to clone the GitHub repository to our local machine:

git clone https://github.com/SnailyCAD/snailycad-bot.git

Once the files have been cloned from GitHub, we can enter that folder:

cd snailycad-bot

2. Installing dependencies​

Now we will install the dependencies that are required for the bot to function properly.

yarn

3. Configuration​

Configuration can be a bit complicated, so pay close attention. The following steps will help you configure the bot's environment variables. These variables are used by the bot to connect to the database.

Tip: In support channels, this will be referenced as the .env file.

3.1 Copy .env.example to .env​

We must first copy the .env.example file to .env:

Windows:

copy .env.example .env

Linux:

cp .env.example .env

Now we can start configuring the variables in the .env file. See next step 3.2 .env file.

3.2 .env info​

  • POSTGRES_PASSWORD: The password to the PostgreSQL database.
  • POSTGRES_USER: The username to the PostgreSQL database.
  • DB_HOST: The database host. Most likely localhost
  • DB_PORT: The port to the database.
  • POSTGRES_DB: The database name.
  • BOT_TOKEN: The token to your bot application.

4. Build the bot​

yarn build

5. Starting the bot​

After completing all the steps above, we are ready to start the bot. To do this run the following command:

yarn start
tip

You can also start the SnailyCAD bot with pm2. Make sure to install it first.

npm install -g pm2

Then run the following command:

pm2 start yarn --name "snailycad-bot" -- start

6. Using the bot​

Head over to the the next section to learn how to use the bot.

Was this page helpful?