Discord role bot.
Typescript Discord bot which assigns roles to users.
A Docker container is provided with NodeJS and Yarn installed. Docker and Docker Compose must be installed.
To run and develop the bot:
- Start the Docker Compose stack:
docker-compose up -d
NodeJS and Yarn must be installed.
To run and develop the bot:
- Install dependencies:
yarn install
- Source environment variables
source ./.env
- Start development watch serer:
yarn watch
Environment variables are used to provide all configuration values. See the Config
class field documentation comments in config.ts
for names of associated environment variables and their purposes.
The .env
file is expected to have configuration values. This file is ignored by Git as some values are secret.
- Copy
.env-example
to.env
and set your own values - Never commit the
.env
file
The chat bot requires the Discord API.
To authenticate with the Discord API you must create a Discord API Application:
- Navigate to the Discord Developer Portal
- Create a new application
- Navigate to the Bot page and add a bot
- Find values for configuration:
ROLE_BOT_DISCORD_CLIENT_ID
: Go to your Discord application's General Information page, use the "APPLICATION ID" valueROLE_BOT_DISCORD_API_TOKEN
: Go to your Discord application's Bot page, use the "TOKEN" value
The ROLE_BOT_DISCORD_GUILD_IDS
environment variable specifies for which Discord servers the bot will install and respond to commands.
The environment variable value is a list of server nicknames, and their guild IDs. The server nickname is just a name this chat bot will use to internally to refer to a Discord server.
List items are in the format <nickname>=<guild ID>
. They are separated by commas.
For example a value of:
games=xyz,school=123
Represents a list with 2 items:
Nickname Guild ID games xyz school 123
To find a Discord server's guild ID:
- Enable developer mode in your Discord:
1.1. Open your Discord
1.2. Go to settings
1.3. In the Advanced tab enable the Developer mode option - Retrieve a Discord server's guild ID:
2.1. View your server list on the left-hand side of the Discord client
2.2. Right click on the server for which you want to retrieve the ID
2.3. At the very bottom of the right-click menu select Copy ID, use this value