Feature/3 disable commands #50

Merged
Vylpes merged 4 commits from feature/3-disable-commands into develop 2021-09-24 19:00:08 +01:00
4 changed files with 7 additions and 1 deletions
Showing only changes of commit 3392e6f031 - Show all commits

View file

@ -12,4 +12,5 @@ BOT_PREFIX=v!
FOLDERS_COMMANDS=commands
FOLDERS_EVENTS=events
COMMANDS_DISABLED=
COMMANDS_DISABLED=
COMMANDS_DISABLED_MESSAGE=This command is disabled.

View file

@ -16,6 +16,7 @@ FOLDERS_COMMANDS=commands
FOLDERS_EVENTS=events
COMMANDS_DISABLED=
COMMANDS_DISABLED_MESSAGE=This command is disabled.
```
* **BOT_TOKEN:** Your bot's token, replace {TOKEN} with your bot token.
@ -23,6 +24,7 @@ COMMANDS_DISABLED=
* **FOLDERS_COMMANDS:** The folder which contains your commands.
* **FOLDERS_EVENTS:** The folder which contains your events.
* **COMMANDS_DISABLED:** List of command file names that won't run, separated by commas.
* **COMMANDS_DISABLED_MESSAGE:** The message which is replied to the user who tries to run a disabled command.
Make sure that you **DO NOT** put your .env file into VCS!

View file

@ -21,6 +21,7 @@ export class CoreClient extends Client {
if (!process.env.BOT_PREFIX) throw "BOT_PREFIX is not defined in .env";
if (!process.env.FOLDERS_COMMANDS) throw "FOLDERS_COMMANDS is not defined in .env";
if (!process.env.FOLDERS_EVENTS) throw "FOLDERS_EVENTS is not defined in .env";
if (!process.env.COMMANDS_DISABLED_MESSAGE) throw "COMMANDS_DISABLED_MESSAGE is not defined in .env";
super.on("message", this._events.onMessage);
super.on("ready", this._events.onReady);

View file

@ -25,6 +25,8 @@ export class Util {
const disabledCommands = process.env.COMMANDS_DISABLED?.split(',');
if (disabledCommands?.find(x => x == name)) {
message.reply(process.env.COMMANDS_DISABLED_MESSAGE || "This command is disabled.");
return {
VylpesTester commented 2021-09-24 18:13:59 +01:00 (Migrated from github.com)
Review

When this returns, what it should do is reply to the user also, to say its disabled

When this returns, what it should do is reply to the user also, to say its disabled
valid: false,
message: "Command is disabled",