allow toggling spam detection
This commit is contained in:
parent
3c45dd110c
commit
7062d8e469
2 changed files with 38 additions and 18 deletions
|
@ -10,12 +10,12 @@ export default {
|
|||
description: 'Perform administrative actions',
|
||||
category: CommandCategory.Config,
|
||||
run: async (message: MessageCommandContext, args: string[]) => {
|
||||
if (!isBotManager(message)) return message.reply(NO_MANAGER_MSG);
|
||||
if (!await isBotManager(message)) return message.reply(NO_MANAGER_MSG);
|
||||
|
||||
try {
|
||||
let action = args.shift();
|
||||
switch(action) {
|
||||
case 'ignore_blacklist':
|
||||
try {
|
||||
case 'ignore_blacklist': {
|
||||
if (args[0] == 'yes') {
|
||||
await dbs.SERVERS.update({ id: message.serverContext._id }, { $set: { allowBlacklistedUsers: true } });
|
||||
await message.reply('Globally blacklisted users will no longer get banned in this server. Previously banned users will need to be unbanned manually.');
|
||||
|
@ -25,19 +25,39 @@ export default {
|
|||
} else {
|
||||
await message.reply(`Please specify either 'yes' or 'no' to toggle this setting.`);
|
||||
}
|
||||
} catch(e) {
|
||||
console.error(''+e);
|
||||
message.reply('Something went wrong: ' + e);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'spam_detection': {
|
||||
if (args[0] == 'on') {
|
||||
await dbs.SERVERS.update({ id: message.serverContext._id }, { $set: { antispamEnabled: true } });
|
||||
await message.reply('Spam detection is now enabled in this server.\nIf a user wrongfully gets kicked '
|
||||
+ 'or banned, please report it here: https://rvlt.gg/jan\n\n'
|
||||
+ 'Please make sure to grant AutoMod permission to **Kick**, **Ban** and **Manage Messages**!');
|
||||
} else if (args[0] == 'off') {
|
||||
await dbs.SERVERS.update({ id: message.serverContext._id }, { $set: { antispamEnabled: false } });
|
||||
await message.reply('Spam detection is now disabled in this server.');
|
||||
|
||||
} else {
|
||||
const cfg = await dbs.SERVERS.findOne({ id: message.serverContext._id });
|
||||
await message.reply(`Spam detection is currently **${cfg?.antispamEnabled ? 'enabled' : 'disabled'}**. `
|
||||
+ `Please specify either 'on' or 'off' to toggle this setting.`);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case undefined:
|
||||
case '':
|
||||
message.reply(`### Available subcommands\n`
|
||||
+ `- \`ignore_blacklist\` - Ignore the bot's global blacklist.`);
|
||||
+ `- \`ignore_blacklist\` - Ignore the bot's global blacklist.\n`
|
||||
+ `- \`spam_detection\` - Toggle automatic spam detection.\n`);
|
||||
break
|
||||
default:
|
||||
message.reply(`Unknown option`);
|
||||
}
|
||||
} catch(e) {
|
||||
console.error(''+e);
|
||||
message.reply('Something went wrong: ' + e);
|
||||
}
|
||||
}
|
||||
} as SimpleCommand;
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue