From dfab642cdb451c239d8c0b4f9f868ad24e4af5a6 Mon Sep 17 00:00:00 2001 From: Julian Date: Mon, 8 Mar 2021 10:45:34 +0100 Subject: [PATCH 1/2] refactor caps command --- src/commands/legacy/caps.js | 40 ------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 src/commands/legacy/caps.js diff --git a/src/commands/legacy/caps.js b/src/commands/legacy/caps.js deleted file mode 100644 index b6e01b533..000000000 --- a/src/commands/legacy/caps.js +++ /dev/null @@ -1,40 +0,0 @@ -const util = require('../../util.js'); -const GuildConfig = require('../../GuildConfig'); - -const command = {}; - -command.description = 'Turn caps moderation on or off'; - -command.usage = 'enabled|disabled'; - -command.names = ['caps','capsmod']; - -command.execute = async (message, args, database, bot) => { - //Permission check - if (!message.member.hasPermission('MANAGE_GUILD')) { - await message.channel.send('You need the "Manage Server" permission to use this command.'); - return; - } - - if (!args.length) { - await message.channel.send(await util.usage(message, command.names[0])); - return; - } - - const guildConfig = await GuildConfig.get(message.guild.id); - if (args[0].toLowerCase() === 'enabled') { - guildConfig.caps = true; - await guildConfig.save(); - await message.channel.send('Caps moderation was enabled!') - } - else if (args[0].toLowerCase() === 'disabled') { - guildConfig.caps = false; - await guildConfig.save(); - await message.channel.send('Caps moderation was disabled!') - } - else { - await message.channel.send(await util.usage(message, command.names[0])); - } -}; - -module.exports = command; From b12776cfd14a3e72dc20b162e08d9af484598628 Mon Sep 17 00:00:00 2001 From: Julian Date: Mon, 8 Mar 2021 10:46:01 +0100 Subject: [PATCH 2/2] I forgot how git works --- src/commands/settings/caps.js | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/commands/settings/caps.js diff --git a/src/commands/settings/caps.js b/src/commands/settings/caps.js new file mode 100644 index 000000000..926e20cb8 --- /dev/null +++ b/src/commands/settings/caps.js @@ -0,0 +1,39 @@ +const Command = require('../../Command'); + +class CapsCommand extends Command { + + static description = 'Configure caps moderation (deletes messages with 70%+ caps)'; + + static usage = 'on|off|status'; + + static names = ['caps','capsmod']; + + static userPerms = ['MANAGE_GUILD']; + + async execute() { + if (this.args.length !== 1) { + await this.sendUsage(); + return; + } + + switch (this.args[0].toLowerCase()) { + case "on": + this.guildConfig.caps = true; + await this.guildConfig.save(); + await this.message.channel.send("Enabled caps moderation!") + break; + case "off": + this.guildConfig.caps = false; + await this.guildConfig.save(); + await this.message.channel.send("Disabled caps moderation!") + break; + case "status": + await this.message.channel.send(`Caps moderation is currently ${this.guildConfig.caps === false ? 'disabled' : 'enabled'}.`); + break; + default: + await this.sendUsage(); + } + } +} + +module.exports = CapsCommand;