Add disabled command message reply
This commit is contained in:
parent
a3230cad20
commit
3392e6f031
4 changed files with 7 additions and 1 deletions
|
@ -12,4 +12,5 @@ BOT_PREFIX=v!
|
||||||
FOLDERS_COMMANDS=commands
|
FOLDERS_COMMANDS=commands
|
||||||
FOLDERS_EVENTS=events
|
FOLDERS_EVENTS=events
|
||||||
|
|
||||||
COMMANDS_DISABLED=
|
COMMANDS_DISABLED=
|
||||||
|
COMMANDS_DISABLED_MESSAGE=This command is disabled.
|
|
@ -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!
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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",
|
||||||
|
|
Reference in a new issue