-
Notifications
You must be signed in to change notification settings - Fork 2
Preprogrammed scripts
This section describes the bot's ability to run preprogrammed scripts, which are located in the commands/tools/run.js file.
Below are the scripts that are integrated by default in the bot, but it is also possible to add new scripts.
The command to run these (and custom scripts as well) is
!run <script name> [parameter/s](as described in the Commands section).
| Script name | Parameter/s | Description |
|---|---|---|
| welcome | <@member | id> |
Forces the execution of the guildMemberAdd event for the specified member. |
| goodbye | <@member | id> |
Forces the execution of the guildMemberRemove event for the specified member. |
| assortStats | [update to level] | By adding the XP that is generated by sending a message, this script forces the bot to trigger the update of the roles of the members who are in the database due to level-up, so this is useful in the event that new reward roles (determined by the levelingRewards.json file) have been added in between the current reward roles. If an additional numerical parameter is also provided, the program will understand that it must update the level of the members to the number provided, in case their level is higher. |
Despite the fact that this bot is open-source and therefore you can make all the modifications you want to the code, I have designed this file specifically to execute small pieces of code and not alter the operation of the rest of the program in the process.
To add a new script, you'll need to add a new case to the switch statement that handles the execution of the scripts based on the args[0] parameter, as follows:
switch (args[0]) {
case 'welcome':
//Some code ...
break;
case 'goodbye':
//Some code ...
break;
case 'assortStats':
//Some code ...
break;
case 'yourNewScriptName':
//Your new code will be here!
break;
default:
//Some code ...
break;
}If you need to access parameters that the user provides, you will need to access the array args from from index 1.
E.g. const parameter1 = args[1];
💡 In case you have any questions about how to use the bot, or anything else related to this repository, you can make use of the support Discord Server.