Add disabled command message reply

This commit is contained in:
Ethan Lane 2021-09-24 18:46:49 +01:00
parent a3230cad20
commit 3392e6f031
Signed by: Vylpes
GPG key ID: EED233CC06D12504
4 changed files with 7 additions and 1 deletions

View file

@ -13,3 +13,4 @@ FOLDERS_COMMANDS=commands
FOLDERS_EVENTS=events 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 FOLDERS_EVENTS=events
COMMANDS_DISABLED= COMMANDS_DISABLED=
COMMANDS_DISABLED_MESSAGE=This command is 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.
@ -23,6 +24,7 @@ COMMANDS_DISABLED=
* **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. * **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! 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.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_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.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("message", this._events.onMessage);
super.on("ready", this._events.onReady); super.on("ready", this._events.onReady);

View file

@ -25,6 +25,8 @@ export class Util {
const disabledCommands = process.env.COMMANDS_DISABLED?.split(','); const disabledCommands = process.env.COMMANDS_DISABLED?.split(',');
if (disabledCommands?.find(x => x == name)) { if (disabledCommands?.find(x => x == name)) {
message.reply(process.env.COMMANDS_DISABLED_MESSAGE || "This command is disabled.");
return { return {
valid: false, valid: false,
message: "Command is disabled", message: "Command is disabled",