|
| 1 | +# Setting up the bot locally |
| 2 | + |
| 3 | +1. Make sure you have the following prerequisites installed: |
| 4 | + - Git |
| 5 | + - [Yarn](https://classic.yarnpkg.com/en/docs/install) |
| 6 | + - [Docker](https://docs.docker.com/get-docker/) |
| 7 | + |
| 8 | +2. Fork the repository and clone it into the directory of your choice. |
| 9 | + |
| 10 | +> This is not necessary for CodeyBot developers - you can work directly from the main repository. |
| 11 | +
|
| 12 | +3. Set up your Discord testing server. |
| 13 | + |
| 14 | +> For CodeyBot developers, we have our own dedicated testing server - ask your team lead for more details. |
| 15 | +
|
| 16 | +4. Set up your Discord testing bot for Codey, and add your bot to the Discord testing server. Make sure it has the following perms: |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | +5. In your cloned project, create a `dev` folder in `config`, and create a `vars.json` file in it. Fill the JSON file with the corresponding values for each of the variables as described in the main README.md. |
| 21 | + |
| 22 | +6. Make an `.env` file in the root folder of the project, and put your Discord bot's token: |
| 23 | +``` |
| 24 | +DISCORD_TOKEN=<insert token here> |
| 25 | +``` |
| 26 | +DO NOT REVEAL THIS: ANYONE WITH THIS HAS ACCESS TO YOUR BOT. |
| 27 | + |
| 28 | +7. Run `yarn` in the root folder of your project to install all the dependencies required. |
| 29 | + |
| 30 | +### Running the bot using Docker |
| 31 | + |
| 32 | +8. Run `yarn image:build` to create and build the Docker image for the bot. |
| 33 | + |
| 34 | +9. If you run `docker image ls`, you should see `codey:latest` as one of the Docker images. |
| 35 | + |
| 36 | +10. Next, run `yarn start` to start the bot. If this is run successfully, you should see a similar output to the following: |
| 37 | +``` |
| 38 | +yarn run v1.22.18 |
| 39 | +$ docker-compose up -d |
| 40 | +codey-bot is up-to-date |
| 41 | +Done in 1.07s. |
| 42 | +``` |
| 43 | +11. Run `yarn logs` to see the logs of the bot. |
| 44 | + |
| 45 | +12. 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`): |
| 46 | + |
| 47 | +> Codey is up! App version: \<app version> |
| 48 | +
|
| 49 | +13. To stop the bot, run `yarn stop`. To stop the bot and remove the container, run `yarn clean`. |
| 50 | + |
| 51 | +### Running the bot locally |
| 52 | + |
| 53 | +You can choose to run the bot locally instead of using Docker. This is helpful if Docker is not working as intended. |
| 54 | + |
| 55 | +8. Install the dependencies `ghostscript` and `graphicsmagick` locally. This is required for the resume pdf->image converter functionality of Codey. |
| 56 | + |
| 57 | +For example, on Mac and some Linux distros, you can do: |
| 58 | +``` |
| 59 | +sudo apt install ghostscript |
| 60 | +sudo apt install graphicsmagick |
| 61 | +``` |
| 62 | + |
| 63 | +9. 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. |
| 64 | + |
| 65 | +10. Next, run `yarn local:run` to run the bot locally. Note that the logs are printed directly into the console output. |
| 66 | + |
| 67 | +11. 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`): |
| 68 | + |
| 69 | +> Codey is up! App version: \<app version> |
| 70 | +
|
| 71 | +12. If you wish to stop the bot, just stop the command. |
0 commit comments