diff --git a/Xiao.js b/Xiao.js index 4f962f55..906af3bf 100644 --- a/Xiao.js +++ b/Xiao.js @@ -100,6 +100,13 @@ client.on('ready', async () => { client.logger.error(`[LEADERBOARD] Could not parse command-leaderboard.json:\n${err.stack}`); } + // Set up disabled commands + const disabled = await this.client.redis.hgetall('disabled'); + for (const command of Object.keys(disabled)) { + client.registry.commands.get(command).disable(); + client.logger.info(`[DISABLED] Disabled the ${command} command.`); + } + // Import command-last-run.json try { const results = client.importLastRun(); diff --git a/commands/util/disable.js b/commands/util/disable.js index 4a5cdcee..659ff7c2 100644 --- a/commands/util/disable.js +++ b/commands/util/disable.js @@ -20,10 +20,11 @@ module.exports = class DisableCommand extends Command { }); } - run(msg, { command }) { + async run(msg, { command }) { if (!command._enabled) return msg.say(`The \`${command.name}\` command is already disabled.`); if (command.guarded) return msg.say(`The \`${command.name}\` command cannot be disabled.`); command.disable(); + await this.client.redis.hset('disabled', { [command.name]: true }); return msg.say(`Disabled the \`${command.name}\` command.`); } }; diff --git a/commands/util/enable.js b/commands/util/enable.js index 038d7624..5ba767bf 100644 --- a/commands/util/enable.js +++ b/commands/util/enable.js @@ -20,9 +20,10 @@ module.exports = class EnableCommand extends Command { }); } - run(msg, { command }) { + async run(msg, { command }) { if (command._enabled) return msg.say(`The \`${command.name}\` command is already enabled.`); command.enable(); + await this.client.redis.hdel('disabled', command.name); return msg.say(`Enabled the \`${command.name}\` command.`); } };