Greetings to all who have decided to read this post, in which I will talk a little about the architecture that I began to write literally not long ago, and I am looking for like-minded people who would like to develop this project together!
What exactly is this?
This is an architecture that aims to simplify and more efficient development of discord bots based on the popular library discord.js
Description
Discord API in recent years is very advanced and grows more and more functional which is already becoming difficult to manage (I tell you as a person who made bots for popular Russian-language discord servers).
It is not difficult to make a simple bot that writes something into a chat or mutilates and banishes participants if they have broken some certain rules.
And what to do if you need a bot on a particular server that will be responsible for the economy, mini-games built around this economy, convenience for moderators in the form of bans and mutes on roles.
When you start to talk about this unwittingly think that it is just as simple, but there is a problem that is very difficult to solve, over time, the code base grows surplus, or a set of utilities that could be put in separate packages or removed altogether, Working with the database, working over time - all this is very difficult.
What supports the architecture at the moment?
- Environment Vars (.env)
- Database (TypeORM)
- Full TypeScript (ts-node)
- Flexible config file
- Hot Reload
- Interactions router
- Locales (i18n)
Interactions router
Instead of creating a script that will automatically load commands or context menus, I decided to make a better way to load certain scripts.
There is a file called interactions.json
this file has full links to some scripts.
{
"commands": {
"example": "~/interactions/commands/example.ts"
},
"user_context_menu": {
"Log in Console": "~/interactions/context_menus/example.ts"
},
"message_context_menu": {},
"buttons": {
"delete": "~/interactions/buttons/delete.ts"
},
"select_menus": {}
}
~
- This is the path to the project root directory.
So our scripts can lie anywhere and we can turn them off at any time.
Contribute to this project <3 (Please help me!)
intellcreatio / intellcreatio
Architecture for Discord Bot
IntellCreatio
Architecture for Discord bot, for convenient operation.
To configure the bot, you must refer to two files in this project, that is config.ts
and .env.example
.
.env.example - rename file to .env
and configure the file.
config.ts - This file is needed to fully configure the bot, you can also add those fields you want but be careful with those fields that already exist.
Locales
Locales storage in folder locales
it's you can change in src/consts.ts
change value const LOCALES_FOLDER_NAME
to yourself
Database configuration (TypeORM)
Locate in database.config.ts
Entities
Located at the root of the project in the entities
folder, where you create models for the database and then connect these entities in database.config.ts
Top comments (0)