From 66fcd3fe124bcf5f5bc86b267a348453a8c7aa0d Mon Sep 17 00:00:00 2001 From: Essem Date: Wed, 6 Jul 2022 19:16:38 -0500 Subject: [PATCH] Fix command, update docs --- commands/general/command.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/commands/general/command.js b/commands/general/command.js index 380fa53..b6f156f 100644 --- a/commands/general/command.js +++ b/commands/general/command.js @@ -7,23 +7,22 @@ class CommandCommand extends Command { if (!this.channel.guild) return "This command only works in servers!"; const owners = process.env.OWNER.split(","); if (!this.member.permissions.has("administrator") && !owners.includes(this.member.id)) return "You need to be an administrator to enable/disable me!"; - if (this.args.length === 0) return "You need to provide what command to enable/disable!"; + if (this.args.length === 0) return "You need to provide whether you want to enable/disable a command!"; if (this.args[0] !== "disable" && this.args[0] !== "enable") return "That's not a valid option!"; + if (!this.args[1]) return "You need to provide what command to enable/disable!"; + if (!collections.commands.has(this.args[1].toLowerCase()) && !collections.aliases.has(this.args[1].toLowerCase())) return "That isn't a command!"; const guildDB = await db.getGuild(this.channel.guild.id); const disabled = guildDB.disabled_commands ?? guildDB.disabledCommands; + const command = collections.aliases.get(this.args[1].toLowerCase()) ?? this.args[1].toLowerCase(); if (this.args[0].toLowerCase() === "disable") { - if (!collections.commands.has(this.args[1].toLowerCase()) && !collections.aliases.has(this.args[1].toLowerCase())) return "That isn't a command!"; - const command = collections.aliases.get(this.args[1].toLowerCase()) ?? this.args[1].toLowerCase(); if (command === "command") return "You can't disable that command!"; if (disabled && disabled.includes(command)) return "That command is already disabled!"; await db.disableCommand(this.channel.guild.id, command); return `The command has been disabled. To re-enable it, just run \`${guildDB.prefix}command enable ${command}\`.`; } else if (this.args[0].toLowerCase() === "enable") { - if (!collections.commands.has(this.args[1].toLowerCase()) && !collections.aliases.has(this.args[1].toLowerCase())) return "That isn't a command!"; - const command = collections.aliases.get(this.args[1].toLowerCase()) ?? this.args[1].toLowerCase(); if (disabled && !disabled.includes(command)) return "That command isn't disabled!"; await db.enableCommand(this.channel.guild.id, command);