A Discord.js bot for managing RP things.
All bot components run on separate docker images managed by docker-compose. The bot itself is defined by a docker image from dockerhub.
A MongoDB stores data objects such as sessions, characters, qotds and more.
A Redis Cache offers configuration values and translation strings.
Internally, the bot uses inversify.js for Dependency Injection (DI).
Controllers are the central distributing logic that handle different tasks in the bot at runtime.
Services provide useful functions to the bot, mostly for repeating actions such as fetching a discord user.
Providers provide data such as configuration values from external systems or interface data for libraries.
Models provide the data structure and Mappers helps map them.
Commands are definitions and logic of commands which represent the interface to the user.
The starting point of the bot is the index.ts which starts up the bot. The server.ts starts the actual server and event subscribers.
String and Emoji values in the database are in UPPER-KEBAB-CASE with dots (.
) separating
the categories. They are prefixed by a STRINGS
or EMOJIS
key prefix respectively:
// String
STRINGS.CATEGORY.ANOTHER-CATEGORY.LAST-CATEGORY
// Emoji
EMOJIS.CATEGORY.ANOTHER-CATEGORY.LAST-CATEGORY
Configuration values are in PascalCamelCase. They are prefixed by a `CONFIGURATION` key prefix:
CONFIGURATION_SomeCategory_SomeConfigurationValue
.env
file in the root of the project with the following values:# ORCHESTRATION
BOT_VERSION=[SemVer]
ENVIRONMENT=local
# SECRETS
TOKEN=[THE_BOT_TOKEN]
# MONGODB
MONGODB_CONNSTR=mongodb://xenon-user:dev-user@localhost:27017/xenon?authSource=admin
MONGODB_ROOT_USER=xenon-admin
MONGODB_ROOT_PASS=dev-admin
MONGODB_ROOT_NAME=admin
MONGODB_USER=xenon-user
MONGODB_PASS=dev-user
MONGODB_NAME=xenon
# REDIS
REDIS_CONNSTR=redis://default:dev@localhost:6379
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASS=dev
# CONFIGURATION
BOT_OWNER_ID=[YOUR_DISCORD_ID]
GUILD_ID=[GUILD_ID_WHERE_BOT_SHOULD_WORK]
# LOGGING
BASE_LOG_LEVEL=trace
SERVICE_LOG_LEVEL=trace
COMMAND_LOG_LEVEL=trace
PROVIDER_LOG_LEVEL=trace
IGNORE_STACK_LEVELS=6
NOTE: Setting your environment to local will not execute command definitions against the discord API. To register commands, use a different environment value once.
npm install
npm run start
With Live Reload:
npm run watch
docker-compose up -d xenon-mongodb xenon-redis
The MongoDB will be started with the authentication database admin
that will contain the user xenon-user
with the
password dev-user
(specified in the dotenv file). The user has read and write permissions on the xenon
database (also
specified in dotenv file).
docker run -v redisinsight:/db -p 8001:8001 redislabs/redisinsight:latest
The redis database will be created with one default user, and the password specified in the dotenv file.
Open localhost:8001
and connect to existing database with these values:
ifconfig -a
).env
fileEnter the connection string from the dotenv file and connect.
To manage strings, either add them manually in RedisInsight or use the script in orchestration/redis/import-strings.sh
.
The script will only work on the local machine.