Redis disabled commands

This commit is contained in:
Dragon Fire
2024-03-30 01:10:39 -04:00
parent 4d88d529df
commit 5153a201f6
3 changed files with 11 additions and 2 deletions
+7
View File
@@ -100,6 +100,13 @@ client.on('ready', async () => {
client.logger.error(`[LEADERBOARD] Could not parse command-leaderboard.json:\n${err.stack}`); 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 // Import command-last-run.json
try { try {
const results = client.importLastRun(); const results = client.importLastRun();
+2 -1
View File
@@ -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._enabled) return msg.say(`The \`${command.name}\` command is already disabled.`);
if (command.guarded) return msg.say(`The \`${command.name}\` command cannot be disabled.`); if (command.guarded) return msg.say(`The \`${command.name}\` command cannot be disabled.`);
command.disable(); command.disable();
await this.client.redis.hset('disabled', { [command.name]: true });
return msg.say(`Disabled the \`${command.name}\` command.`); return msg.say(`Disabled the \`${command.name}\` command.`);
} }
}; };
+2 -1
View File
@@ -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.`); if (command._enabled) return msg.say(`The \`${command.name}\` command is already enabled.`);
command.enable(); command.enable();
await this.client.redis.hdel('disabled', command.name);
return msg.say(`Enabled the \`${command.name}\` command.`); return msg.say(`Enabled the \`${command.name}\` command.`);
} }
}; };