diff options
Diffstat (limited to 'src/commands/moderation')
-rw-r--r-- | src/commands/moderation/ban.ts | 2 | ||||
-rw-r--r-- | src/commands/moderation/hideCase.ts | 50 | ||||
-rw-r--r-- | src/commands/moderation/modlog.ts | 45 | ||||
-rw-r--r-- | src/commands/moderation/purge.ts | 9 | ||||
-rw-r--r-- | src/commands/moderation/unban.ts | 2 |
5 files changed, 84 insertions, 24 deletions
diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts index 5a1b5d9..812d7ca 100644 --- a/src/commands/moderation/ban.ts +++ b/src/commands/moderation/ban.ts @@ -126,7 +126,7 @@ export default class BanCommand extends BushCommand { duration: time! ?? 0, deleteDays: days ?? 0 }) - : await message.guild.ban({ + : await message.guild.bushBan({ user, reason: parsedReason, moderator: message.author, diff --git a/src/commands/moderation/hideCase.ts b/src/commands/moderation/hideCase.ts new file mode 100644 index 0000000..1d8dea6 --- /dev/null +++ b/src/commands/moderation/hideCase.ts @@ -0,0 +1,50 @@ +import { BushCommand, BushMessage, BushSlashMessage, ModLog } from '@lib'; + +export default class HideCaseCommand extends BushCommand { + public constructor() { + super('hideCase', { + aliases: ['hidecase', 'hide_case', 'showcase', 'show_case', 'coverupmodabuse', 'cover_up_mod_abuse'], + category: 'moderation', + description: { + content: 'Hide a particular modlog case from the modlog command unless the `--hidden` flag is specified', + usage: 'hideCase <caseID>', + examples: ['hideCase 9210b1ea-91f5-4ea2-801b-02b394469c77'] + }, + args: [ + { + id: 'case', + type: 'string', + prompt: { + start: 'What modlog case would you like to hide?', + retry: '{error} Choose a valid case id.' + } + } + ], + userPermissions: ['MANAGE_MESSAGES'], + slash: true, + slashOptions: [ + { + name: 'case', + description: 'What modlog case would you like to hide?', + type: 'STRING', + required: true + } + ], + channel: 'guild' + }); + } + + public override async exec(message: BushMessage | BushSlashMessage, { case: caseID }: { case: string }): Promise<unknown> { + if (message.author.id === '496409778822709251') + return await message.util.reply(`${util.emojis.error} This command is Bestower proof.`); + const entry = await ModLog.findByPk(caseID); + if (!entry || entry.pseudo) return message.util.send(`${util.emojis.error} Invalid entry.`); + if (entry.guild !== message.guild!.id) + return message.util.reply(`${util.emojis.error} This modlog is from another server.`); + const action = entry.hidden ? 'now hidden' : 'no longer hidden'; + entry.hidden = !entry.hidden; + await entry.save(); + + return await message.util.reply(`${util.emojis.success} CaseID \`${caseID}\` is ${action}.`); + } +} diff --git a/src/commands/moderation/modlog.ts b/src/commands/moderation/modlog.ts index fd53ea7..0be6971 100644 --- a/src/commands/moderation/modlog.ts +++ b/src/commands/moderation/modlog.ts @@ -1,5 +1,5 @@ import { BushCommand, BushMessage, BushSlashMessage, BushUser, ModLog } from '@lib'; -import { MessageEmbed, User } from 'discord.js'; +import { User } from 'discord.js'; export default class ModlogCommand extends BushCommand { public constructor() { @@ -8,7 +8,7 @@ export default class ModlogCommand extends BushCommand { category: 'moderation', description: { content: "View a user's modlogs, or view a specific case.", - usage: 'modlogs <search>', + usage: 'modlogs <search> [--hidden]', examples: ['modlogs @Tyman'] }, args: [ @@ -19,6 +19,12 @@ export default class ModlogCommand extends BushCommand { start: 'What case id or user would you like to see?', retry: '{error} Choose a valid case id or user.' } + }, + { + id: 'hidden', + match: 'flag', + flags: ['--hidden', '-h'], + default: false } ], userPermissions: ['MANAGE_MESSAGES'], @@ -29,6 +35,12 @@ export default class ModlogCommand extends BushCommand { description: 'What case id or user would you like to see?', type: 'STRING', required: true + }, + { + name: 'hidden', + description: 'Would you like to see hidden modlogs?', + type: 'BOOLEAN', + required: false } ] }); @@ -50,7 +62,7 @@ export default class ModlogCommand extends BushCommand { public override async exec( message: BushMessage | BushSlashMessage, - { search }: { search: BushUser | string } + { search, hidden }: { search: BushUser | string; hidden: boolean } ): Promise<unknown> { const foundUser = search instanceof User ? search : await util.resolveUserAsync(search); if (foundUser) { @@ -62,28 +74,25 @@ export default class ModlogCommand extends BushCommand { order: [['createdAt', 'ASC']] }); if (!logs.length) return message.util.reply(`${util.emojis.error} **${foundUser.tag}** does not have any modlogs.`); - const niceLogs: string[] = []; - for (const log of logs) { - niceLogs.push(this.#generateModlogInfo(log)); - } + const niceLogs = logs.filter((log) => !log.pseudo && !log.hidden && !hidden).map((log) => this.#generateModlogInfo(log)); const chunked: string[][] = util.chunk(niceLogs, 3); - const embedPages = chunked.map( - (chunk) => - new MessageEmbed({ - title: `${foundUser.tag}'s Mod Logs`, - description: chunk.join('\n━━━━━━━━━━━━━━━\n'), - color: util.colors.default - }) - ); + const embedPages = chunked.map((chunk) => ({ + title: `${foundUser.tag}'s Mod Logs`, + description: chunk.join('\n━━━━━━━━━━━━━━━\n'), + color: util.colors.default + })); return await util.buttonPaginate(message, embedPages, undefined, true); } else if (search) { const entry = await ModLog.findByPk(search as string); - if (!entry) return message.util.send(`${util.emojis.error} That modlog does not exist.`); - const embed = new MessageEmbed({ + if (!entry || entry.pseudo || (entry.hidden && !hidden)) + return message.util.send(`${util.emojis.error} That modlog does not exist.`); + if (entry.guild !== message.guild!.id) + return message.util.reply(`${util.emojis.error} This modlog is from another server.`); + const embed = { title: `Case ${entry.id}`, description: this.#generateModlogInfo(entry), color: util.colors.default - }); + }; return await util.buttonPaginate(message, [embed]); } } diff --git a/src/commands/moderation/purge.ts b/src/commands/moderation/purge.ts index b391ff6..4ed1ee7 100644 --- a/src/commands/moderation/purge.ts +++ b/src/commands/moderation/purge.ts @@ -47,18 +47,19 @@ export default class PurgeCommand extends BushCommand { if (message.channel.type === 'DM') return message.util.reply(`${util.emojis.error} You cannot run this command in dms.`); if (args.amount > 100 || args.amount < 1) return message.util.reply(`${util.emojis.error} `); - const messages = (await message.channel.messages.fetch({ limit: args.amount })).filter((message) => filter(message)); - const filter = (filterMessage: BushMessage): boolean => { + const messageFilter = (filterMessage: BushMessage): boolean => { const shouldFilter = new Array<boolean>(); if (args.bot) { shouldFilter.push(filterMessage.author.bot); } return shouldFilter.filter((bool) => bool === false).length === 0; }; + const messages = (await message.channel.messages.fetch({ limit: args.amount })).filter((message) => messageFilter(message)); - const purged = await message.channel.bulkDelete(messages, true).catch(() => {}); - if (!purged) return message.util.reply(`${util.emojis.error} Failed to purge messages.`).catch(() => {}); + const purged = await message.channel.bulkDelete(messages, true).catch(() => null); + if (!purged) return message.util.reply(`${util.emojis.error} Failed to purge messages.`).catch(() => null); else { + client.emit('bushPurge', message.author, message.guild!, message.channel, messages); await message.util .send(`${util.emojis.success} Successfully purged **${purged.size}** messages.`) .then(async (purgeMessage) => { diff --git a/src/commands/moderation/unban.ts b/src/commands/moderation/unban.ts index 3436da6..5025ede 100644 --- a/src/commands/moderation/unban.ts +++ b/src/commands/moderation/unban.ts @@ -59,7 +59,7 @@ export default class UnbanCommand extends BushCommand { user = util.resolveUser(user, client.users.cache) as BushUser; } - const responseCode = await message.guild!.unban({ + const responseCode = await message.guild!.bushUnban({ user, moderator: message.author, reason |