|
| 1 | +# Hosting your own instance |
| 2 | + |
| 3 | +This bot is built on [discord.js](https://discord.js.org/#/) v13, so you'll need |
| 4 | +Node.js 16.6.0 (or newer) installed. You will also need your own Discord bot |
| 5 | +account. If your platform does not have Node.js 16.6.0, consider using something |
| 6 | +like https://github.com/nvm-sh/nvm. |
| 7 | + |
| 8 | +This guide assumes you're hosting on a Linux distro with `systemd`. The bot will |
| 9 | +work on other platforms, but you're on your own figuring that out. |
| 10 | + |
| 11 | +## Running as a user (in dev-mode) |
| 12 | +Quick and easy. Also (mostly) platform-independent! |
| 13 | + |
| 14 | +Create a file `config.json` and paste in the following (obviously fill in the |
| 15 | +blanks with your bot's info): |
| 16 | +```json |
| 17 | +{ |
| 18 | + "token": "<your token here>", |
| 19 | + "app_id": "<your bot application ID here>" |
| 20 | +} |
| 21 | +``` |
| 22 | + |
| 23 | +Install dependencies, register Discord slash commands, and set up the database |
| 24 | +for your bot: |
| 25 | +``` |
| 26 | +git clone https://github.com/Mimickal/ReactionRoleBot.git |
| 27 | +cd ReactionRoleBot |
| 28 | +npm ci |
| 29 | +npm run register path/to/your/config.json |
| 30 | +npm run knex migrate:latest |
| 31 | +``` |
| 32 | + |
| 33 | +Start the bot: |
| 34 | +``` |
| 35 | +npm start path/to/your/config.json |
| 36 | +``` |
| 37 | + |
| 38 | +## Running as a service |
| 39 | +A little more effort to set up, but better for long-term use. |
| 40 | + |
| 41 | +The provided service file expects to find the bot code at |
| 42 | +`/srv/discord/ReactionRoleBot/`, and will want to create the sqlite database at |
| 43 | +`/srv/discord/rolebot.sqlite`. The easiest way to do this is to create a |
| 44 | +`/srv/discord` directory, and `chown` it so it belongs to the user running the |
| 45 | +bot. |
| 46 | + |
| 47 | +Create a file `/etc/discord/ReactionRoleBot/config.json` and paste in the |
| 48 | +following (obviously fill in the blanks with your bot's info): |
| 49 | +```json |
| 50 | +{ |
| 51 | + "token": "<your token here>", |
| 52 | + "app_id": "<your bot application ID here>" |
| 53 | +} |
| 54 | +``` |
| 55 | + |
| 56 | +The following will prepare the bot to run by installing dependencies, |
| 57 | +registering slash commands for your Discord bot account, and setting up the |
| 58 | +bot's database. Run this from `/srv/discord`: |
| 59 | +``` |
| 60 | +git clone https://github.com/Mimickal/ReactionRoleBot.git |
| 61 | +cd ReactionRoleBot |
| 62 | +npm ci |
| 63 | +npm run register /etc/discord/ReactionRoleBot/config.json |
| 64 | +NODE_ENV=prod npm run knex migrate:latest |
| 65 | +``` |
| 66 | + |
| 67 | +Add your user to `reactionrolebot.service`, then install it into |
| 68 | +`/etc/systemd/system/` (just copy the file into that directory). This service |
| 69 | +file depends on the above directories, so if you want to change them, you'll |
| 70 | +also need to edit those fields. If you are using `nvm`, you may need to tweak |
| 71 | +the service file a bit (see comments in provided service file). |
| 72 | + |
| 73 | +Now you should be able to run `systemctl restart reactionrolebot.service` to |
| 74 | +start your bot. |
0 commit comments