-
Notifications
You must be signed in to change notification settings - Fork 1
Installation
Clone this repo into your linux environment.
docker
Visit the Discord Developer Portal and create an application.
Make note of your:
-
Application ID
found underGeneral Information
-
Bot Token
found underBot
Create a private discord server to test the bot on.
To authorize the bot with the necessary permissions (Create commands in a server
) to join your server, build the url as follows (taken from the discord.js
guide):
https://discord.com/api/oauth2/authorize?client_id=<APPLICATION_ID>&permissions=0&scope=bot%20applications.commands
Copy .env.template
to .env
:
$ cp .env.template .env
$ vi .env
Fill in missing variables in .env
, such as the Discord Token and App ID. Edit any others as desired. If you are deploying to a server, copy the server id to the DEV_GUILD_ID
variable. The server id is found in Discord through these steps:
- Enable
Developer Mode
in the Discord App - Right click on the server and select
Copy ID
Run the following command to build an image from source:
$ docker compose build
Use the discord-utils.js
script to deploy the bot commands to your dev server or globally to all servers. You can either run the script in a container, or locally if you have node.js
installed.
Run this command to view the script options:
$ docker run --env-file .env -it xx-monitor-bot-bot node built/discord/discord-utils.js
You may choose to deploy globally or to a specific server. Deploying globally allows users to interact with the bot over Direct Messages. Don't deploy to both, however, because the commands will appear multiple times in the Discord UI.
To deploy globally:
$ docker run --env-file .env -it xx-monitor-bot-bot node built/discord/discord-utils.js deploy --global
To deploy to a server:
$ docker run --env-file .env -it xx-monitor-bot-bot node built/discord/discord-utils.js deploy
To un-deploy:
$ docker run --env-file .env -it xx-monitor-bot-bot node built/discord/discord-utils.js --reset
To deploy changes you make to the SlashCommandBuilder
object in your commands:
Just deploy as you originally did, either globally or to a server.
$ docker run --env-file .env -it xx-monitor-bot-bot node built/discord/discord-utils.js username "xx monitor bot"
$ docker run --env-file .env --volume <image path, e.g. ./image.jpg>:/image -it xx-monitor-bot-bot node built/discord/discord-utils.js avatar /image
Use the following commands to install the required packages and publish the slash commands to your server:
$ npm install
$ npm run build
$ node built/discord/discord-utils.js help
$ [... command output ...]
You can also set the bot username and status with the BOT_USERNAME
and BOT_STATUS
variables in .env
and they will be set each time the bot starts.
Run the following command to start the bot in the background:
$ docker compose up -d
To view the logs of the running containers, try the following commands:
$ docker compose logs # shows most recent logs from all containers
$ docker compose logs -f # follows the log output of all containers continuously
$ docker compose logs -f bot # follows the bot console continuously