Add ability to disable commands

This commit is contained in:
Ethan Lane 2021-09-22 19:54:49 +01:00
parent 10fe4501b5
commit 4e1c418246
Signed by: Vylpes
GPG key ID: EED233CC06D12504
3 changed files with 19 additions and 5 deletions

View file

@ -11,3 +11,5 @@ BOT_PREFIX=v!
FOLDERS_COMMANDS=commands FOLDERS_COMMANDS=commands
FOLDERS_EVENTS=events FOLDERS_EVENTS=events
COMMANDS_DISABLED=

View file

@ -14,12 +14,15 @@ BOT_PREFIX=v!
FOLDERS_COMMANDS=commands FOLDERS_COMMANDS=commands
FOLDERS_EVENTS=events FOLDERS_EVENTS=events
COMMANDS_DISABLED=
``` ```
* **BOT_TOKEN:** Your bot's token, replace {TOKEN} with your bot token * **BOT_TOKEN:** Your bot's token, replace {TOKEN} with your bot token.
* **BOT_PREFIX** The command prefix * **BOT_PREFIX:** The command prefix.
* **FOLDERS_COMMANDS:** The folder which contains your commands * **FOLDERS_COMMANDS:** The folder which contains your commands.
* **FOLDERS_EVENTS** The folder which contains your events * **FOLDERS_EVENTS:** The folder which contains your events.
* **COMMANDS_DISABLED:** List of command file names that won't run, separated by commas.
Make sure that you **DO NOT** put your .env file into VCS! Make sure that you **DO NOT** put your .env file into VCS!

View file

@ -22,6 +22,15 @@ export class Util {
message: "Member is not part of message", message: "Member is not part of message",
}; };
const disabledCommands = process.env.COMMANDS_DISABLED?.split(',');
if (disabledCommands?.find(x => x == name)) {
return {
valid: false,
message: "Command is disabled",
};
}
const folder = process.env.FOLDERS_COMMANDS; const folder = process.env.FOLDERS_COMMANDS;
if (existsSync(`${process.cwd()}/${folder}/`)) { if (existsSync(`${process.cwd()}/${folder}/`)) {