GitHub Repository Statistics/Info:
Language:
Fork/Download For:
Note: All IDs need to be saved as a string because usual discord IDs are long numbers. MongoDB and json both round up the numbers.
You can set the bot's owners in config.json. You need to add the ownerss discord IDs to the "owners" list. When you enter the IDs make sure to enclose them in double quotes. e.g.: {"owners": ["ID1", "ID2"]}
Supported database is MongoDB. You can enable the database by setting the database key to true. You need a link/IP address for the bot (e.g.: mongodb://root:<password>@link.mongodb.net/mydb or mongodb://mongo:27017/mydb or mongodb://172.19.0.2/). For local database use docker-compose.yml.
The bot can work in two ways. Either use a database or don't.
If the bot uses database, the logic when the bot receives a message on a server that is not in the database, it registers it. The basic settings will be the default section in the config file. After that, you can modify the settings with pre-prepared commands.
If the bot does not use a database, default section will apply to all servers. The manager section does not need to be modified. Regardless of whether you use a database or not, the bot saves the settings automatically.
e.g.:
"groups": {
"name1": ["ROLE_ID1", "ROLE_ID2"],
"name2": ["ROLE_ID1", "ROLE_ID2"]
}Under commands and slashCommands directories, you can put the commands right into the directory or into subdirectories. The bot will automatically load the commands regardless of whether the file is in a subdirectory or not. There are some settings you can specify in the commands files. Some of theme are: name, enabled, description, cooldown, permissions, help, ...
If the bot uses database, the logic when the bot registers a new server, it also registers a commands_data section for the server. This includes the name of the command, whether it is enabled and its permissions. The basic settings are the ones you set in the file.
If the bot does not use a database, the settings will be the same in the file for each server.
After checking both the user and the bot have permissions to run this command, the bot tries to start the run function of the command (file).
-
Roles permissions (
roles_permissions) is a section where you can specify that the user and/or bot must have a certain permission. This permission is the permission of roles. (e.g.: Administrator, ManageGuild, ManageChannels, ManageRoles, ...) -
User permissions (
user_permissions) is a section where you can specify that the user must have a permission, not the same type of permission as the previous one. This permission types: owners, guildOnwer, group, role, null.
SlashCommands are just a little different. The difference is that there is an extra section called Slash Register Data.
- Slash Register Data (
slash_register_data) is a section where you can specify default settings for discord slash commands to be registered with.
The lang function can be used to retrieve the text in the language of the given server, you can import the function from utils/lang.js. (const lang = require('./utils/lang.js');)
The syntax for the lang function is: key, language and replacement. You can create new language files or modify them within the language folder.
-
key: Since there are several keys in a json file, they must be entered as one text separated by colons. (
e.g.: 'commands:help:title') -
language: For our language, only the file name of the given language must be entered. Usually the easiest way is to pass the server.language argument to the function. (e.g.:
'en',server.language) -
replacement: Replacement is not a mandatory argument that you have to give. This type is a list. The location of the replacable data in the language files must be marked with
{INDEX}. (e.g.: {0}, {1}, {2})
The database files can be found inside ./utils/db/. The bot connects to the database by calling the connect function from manager.js.
The manager.js returns a connect function and a get section. The get part basically has two parts, server and manager. The bot makes the get section the same as client.get. You may have already figured it out, but with these things we can get certain data. In order to get data belonging to a server, the function client.get.server must be called with a filter for the server ID (e.g.: client.get.server({id: 'MYSERVERID'}), client.get.server({id: interaction.guild.id})). In order to get data belonging to a manager, the function client.get.manager must be called with a filter for the manager's name (e.g.: client.get.manager({id: 'verify'})).
Basically, to make a new table in the database, you need to make a new schema. You can do this in the models.js file. All the Schema's will automatically add, to client.model. (e.g.: client.model.server)
The components must be placed in the folders with the name of their type. Because the bot defines the types based on this and adds it to a Map variable.
