diff options
Diffstat (limited to 'src/commands')
-rw-r--r-- | src/commands/_fake-command/ironmoon.ts | 2 | ||||
-rw-r--r-- | src/commands/config/log.ts | 2 | ||||
-rw-r--r-- | src/commands/info/help.ts | 4 | ||||
-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 | ||||
-rw-r--r-- | src/commands/moulberry-bush/report.ts | 11 |
9 files changed, 94 insertions, 33 deletions
diff --git a/src/commands/_fake-command/ironmoon.ts b/src/commands/_fake-command/ironmoon.ts index 8ca1f5b..ddc6ced 100644 --- a/src/commands/_fake-command/ironmoon.ts +++ b/src/commands/_fake-command/ironmoon.ts @@ -5,7 +5,7 @@ export default class IronmoonCommand extends BushCommand { super('ironmoon', { category: 'fake-commands', description: { content: '', examples: '', usage: '' }, - completelyHide: true + pseudo: true }); } public override condition(message: BushMessage): boolean { diff --git a/src/commands/config/log.ts b/src/commands/config/log.ts index 592f700..0bc2189 100644 --- a/src/commands/config/log.ts +++ b/src/commands/config/log.ts @@ -79,7 +79,7 @@ export default class LogCommand extends BushCommand { ? `${util.emojis.success} Successfully ${oldChannel ? 'changed' : 'set'}` : `${util.emojis.error} Unable to ${oldChannel ? 'change' : 'set'}` } ${ - oldChannel ? ` the \`${args.log_type}\` log channel from <#${oldChannel}>` : ` the \`${args.log_type}\` log channel` + oldChannel ? ` the **${args.log_type}** log channel from <#${oldChannel}>` : ` the \`${args.log_type}\` log channel` } to ${args.channel ? `<#${args.channel.id}>` : '`disabled`'}` ); } diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts index ad4e00f..1338f8a 100644 --- a/src/commands/info/help.ts +++ b/src/commands/info/help.ts @@ -90,14 +90,14 @@ export default class HelpCommand extends BushCommand { : args.command : null; if (!isOwner) args.showHidden = false; - if (!command || command.completelyHide) { + if (!command || command.pseudo) { const embed = new MessageEmbed().setColor(util.colors.default).setTimestamp(); if (message.guild) { embed.setFooter(`For more information about a command use ${prefix}help <command>`); } for (const [, category] of this.handler.categories) { const categoryFilter = category.filter((command) => { - if (command.completelyHide) return false; + if (command.pseudo) return false; if (command.hidden && !args.showHidden) return false; if (command.channel == 'guild' && !message.guild && !args.showHidden) return false; if (command.ownerOnly && !isOwner) return false; 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 diff --git a/src/commands/moulberry-bush/report.ts b/src/commands/moulberry-bush/report.ts index e387e7d..a5c4cb2 100644 --- a/src/commands/moulberry-bush/report.ts +++ b/src/commands/moulberry-bush/report.ts @@ -1,6 +1,6 @@ import { GuildMember, MessageEmbed } from 'discord.js'; import moment from 'moment'; -import { AllowedMentions, BushCommand, BushMessage, BushTextChannel } from '../../lib'; +import { AllowedMentions, BushCommand, BushMessage } from '../../lib'; export default class ReportCommand extends BushCommand { public constructor() { @@ -71,9 +71,11 @@ export default class ReportCommand extends BushCommand { if (member.user.bot) return await message.util.reply(`${util.emojis.error} You cannot report a bot <:WeirdChamp:756283321301860382>.`); - const reportChannelId = (await message.guild.getSetting('logChannels')).report; - if (!reportChannelId) - return await message.util.reply(`${util.emojis.error} This server has not setup a report logging channel.`); + const reportChannel = await message.guild.getLogChannel('report'); + if (!reportChannel) + return await message.util.reply( + `${util.emojis.error} This server has not setup a report logging channel or the channel no longer exists.` + ); //The formatting of the report is mostly copied from carl since it is pretty good when it actually works const reportEmbed = new MessageEmbed() @@ -109,7 +111,6 @@ export default class ReportCommand extends BushCommand { reportEmbed.addField('Attachment', message.attachments.first()!.url); } } - const reportChannel = client.channels.cache.get(reportChannelId) as unknown as BushTextChannel; await reportChannel.send({ embeds: [reportEmbed] }).then(async (ReportMessage) => { try { await ReportMessage.react(util.emojis.check); |