Fixed disabled commands on SQLite

This commit is contained in:
Essem 2021-08-13 14:24:26 -05:00
parent 70a592fa49
commit a75c55a1ca
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C
2 changed files with 5 additions and 4 deletions

View file

@ -10,18 +10,19 @@ class CommandCommand extends Command {
if (this.args[0] !== "disable" && this.args[0] !== "enable") return "That's not a valid option!";
const guildDB = await db.getGuild(this.message.channel.guild.id);
const disabled = guildDB.disabled_commands ? guildDB.disabled_commands : guildDB.disabledCommands;
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.has(this.args[1].toLowerCase()) ? collections.aliases.get(this.args[1].toLowerCase()) : this.args[1].toLowerCase();
if (guildDB.disabled_commands && guildDB.disabled_commands.includes(command)) return "That command is already disabled!";
if (disabled && disabled.includes(command)) return "That command is already disabled!";
await db.disableCommand(this.message.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.has(this.args[1].toLowerCase()) ? collections.aliases.get(this.args[1].toLowerCase()) : this.args[1].toLowerCase();
if (guildDB.disabled_commands && !guildDB.disabled_commands.includes(command)) return "That command isn't disabled!";
if (disabled && !disabled.includes(command)) return "That command isn't disabled!";
await db.enableCommand(this.message.channel.guild.id, command);
return `The command \`${command}\` has been re-enabled.`;

View file

@ -76,8 +76,8 @@ module.exports = async (client, cluster, worker, ipc, message) => {
if (disabledCmds.includes(aliased ? aliased : command)) return;
} else {
guildDB = await database.getGuild(message.channel.guild.id);
collections.disabledCmdCache.set(message.channel.guild.id, guildDB.disabled_commands);
if (guildDB.disabled_commands.includes(aliased ? aliased : command)) return;
collections.disabledCmdCache.set(message.channel.guild.id, guildDB.disabled_commands ? guildDB.disabled_commands : guildDB.disabledCommands);
if ((guildDB.disabled_commands ? guildDB.disabled_commands : guildDB.disabledCommands).includes(aliased ? aliased : command)) return;
}
}