Skip to content

Latest commit

 

History

History
90 lines (53 loc) · 3.59 KB

SETUP.md

File metadata and controls

90 lines (53 loc) · 3.59 KB

Setting up the bot locally

  1. Make sure you have the following prerequisites installed:
  1. Fork the repository and clone it into the directory of your choice.

This is not necessary for CodeyBot developers - you can work directly from the main repository.

  1. Set up your Discord testing server.

For CodeyBot developers, we have our own dedicated testing server - ask your team lead for more details.

  1. Set up your Discord testing bot for Codey. In the Discord Developer Portal, make sure to turn on all intents:

Intents

Also, give the following permissions to your bot:

Bot Permissions

Then, add your bot to the Discord testing server.

  1. In your cloned project, navigate to config/. Duplicate the vars.template.json file, move your copy to the dev folder, and rename your file vars.json. This will be the config file for your local bot. Edit the values in vars.json as according to the following config variable descriptions:
  • BOOTCAMP_GUILD_ID: the ID of the Bootcamp server.
  • NOTIF_CHANNEL_ID: the ID of the channel the bot will send system notifications to.
  • MOD_USER_ID_FOR_BAN_APPEAL: the user ID of the mod tagged in the appeal messages for bans. Note that this file will not be pushed to the remote.
  1. Make an .env file in the root folder of the project, and put your Discord bot's token, which can be found in the Discord Developer Portal. The format of the .env file should be as follows.
DISCORD_TOKEN=<insert token here>

DO NOT REVEAL THE DISCORD_TOKEN; ANYONE WITH THIS TOKEN CAN CONTROL YOUR BOT.

Note that this file will also not be pushed to the remote.

  1. Run yarn in the root folder of your project to install all the dependencies required.

Running the bot using Docker

  1. Run yarn image:build to create and build the Docker image for the bot.

  2. If you run docker image ls, you should see codey:latest as one of the Docker images.

  3. Next, run yarn start to start the bot. If this is run successfully, you should see a similar output to the following:

yarn run v1.22.18
$ docker-compose up -d
codey-bot is up-to-date
Done in 1.07s.
  1. Run yarn logs to see the logs of the bot.

  2. If everything is set up correctly, you should see your bot send a message in the configured notification channel (the channel assigned to NOTIF_CHANNEL_ID in your vars.json):

Codey is up! App version: <app version>

  1. To stop the bot, run yarn stop. To stop the bot and remove the container, run yarn clean.

Running the bot locally

You can choose to run the bot locally instead of using Docker. This is helpful if Docker is not working as intended.

  1. Install the dependencies ghostscript and graphicsmagick locally. This is required for the resume pdf->image converter functionality of Codey.

For example, on Mac and some Linux distros, you can do:

sudo apt install ghostscript
sudo apt install graphicsmagick
  1. Run yarn ts:build to build the bot locally. If this run successfully, you should see a dist folder in your project, which contains all the compiled JS code.

  2. Next, run yarn local:run to run the bot locally. Note that the logs are printed directly into the console output.

  3. If everything is set up correctly, you should see your bot send a message in the configured notification channel (the channel assigned to NOTIF_CHANNEL_ID in your vars.json):

Codey is up! App version: <app version>

  1. If you wish to stop the bot, just stop the command.