From 2874a0cf8328ca2fcabf344166f73e012a90e72a Mon Sep 17 00:00:00 2001 From: Lily Bergonzat Date: Thu, 22 Feb 2024 01:07:19 +0100 Subject: [PATCH] Fixed case type filters --- .../commands/cases/CasesModMsgCmd.ts | 2 ++ .../commands/cases/CasesSlashCmd.ts | 2 ++ .../commands/cases/CasesUserMsgCmd.ts | 2 ++ .../actualCommands/actualCasesCmd.ts | 22 +++++++++++-------- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/backend/src/plugins/ModActions/commands/cases/CasesModMsgCmd.ts b/backend/src/plugins/ModActions/commands/cases/CasesModMsgCmd.ts index 0777e1cf..57f45c74 100644 --- a/backend/src/plugins/ModActions/commands/cases/CasesModMsgCmd.ts +++ b/backend/src/plugins/ModActions/commands/cases/CasesModMsgCmd.ts @@ -11,6 +11,7 @@ const opts = { warns: ct.switchOption({ def: false, shortcut: "w" }), mutes: ct.switchOption({ def: false, shortcut: "m" }), unmutes: ct.switchOption({ def: false, shortcut: "um" }), + kicks: ct.switchOption({ def: false, shortcut: "k" }), bans: ct.switchOption({ def: false, shortcut: "b" }), unbans: ct.switchOption({ def: false, shortcut: "ub" }), show: ct.switchOption({ def: false, shortcut: "sh" }), @@ -38,6 +39,7 @@ export const CasesModMsgCmd = modActionsMsgCmd({ args.warns, args.mutes, args.unmutes, + args.kicks, args.bans, args.unbans, args.reverseFilters, diff --git a/backend/src/plugins/ModActions/commands/cases/CasesSlashCmd.ts b/backend/src/plugins/ModActions/commands/cases/CasesSlashCmd.ts index 9d22d5d7..3e720917 100644 --- a/backend/src/plugins/ModActions/commands/cases/CasesSlashCmd.ts +++ b/backend/src/plugins/ModActions/commands/cases/CasesSlashCmd.ts @@ -15,6 +15,7 @@ const opts = [ slashOptions.boolean({ name: "warns", description: "To filter warns", required: false }), slashOptions.boolean({ name: "mutes", description: "To filter mutes", required: false }), slashOptions.boolean({ name: "unmutes", description: "To filter unmutes", required: false }), + slashOptions.boolean({ name: "kicks", description: "To filter kicks", required: false }), slashOptions.boolean({ name: "bans", description: "To filter bans", required: false }), slashOptions.boolean({ name: "unbans", description: "To filter unbans", required: false }), slashOptions.boolean({ name: "show", description: "To make the result visible to everyone", required: false }), @@ -39,6 +40,7 @@ export const CasesSlashCmd = { options.warns, options.mutes, options.unmutes, + options.kicks, options.bans, options.unbans, options["reverse-filters"], diff --git a/backend/src/plugins/ModActions/commands/cases/CasesUserMsgCmd.ts b/backend/src/plugins/ModActions/commands/cases/CasesUserMsgCmd.ts index a185950e..c65226a6 100644 --- a/backend/src/plugins/ModActions/commands/cases/CasesUserMsgCmd.ts +++ b/backend/src/plugins/ModActions/commands/cases/CasesUserMsgCmd.ts @@ -13,6 +13,7 @@ const opts = { warns: ct.switchOption({ def: false, shortcut: "w" }), mutes: ct.switchOption({ def: false, shortcut: "m" }), unmutes: ct.switchOption({ def: false, shortcut: "um" }), + kicks: ct.switchOption({ def: false, shortcut: "k" }), bans: ct.switchOption({ def: false, shortcut: "b" }), unbans: ct.switchOption({ def: false, shortcut: "ub" }), show: ct.switchOption({ def: false, shortcut: "sh" }), @@ -51,6 +52,7 @@ export const CasesUserMsgCmd = modActionsMsgCmd({ args.warns, args.mutes, args.unmutes, + args.kicks, args.bans, args.unbans, args.reverseFilters, diff --git a/backend/src/plugins/ModActions/functions/actualCommands/actualCasesCmd.ts b/backend/src/plugins/ModActions/functions/actualCommands/actualCasesCmd.ts index 24c5a356..9bb2d580 100644 --- a/backend/src/plugins/ModActions/functions/actualCommands/actualCasesCmd.ts +++ b/backend/src/plugins/ModActions/functions/actualCommands/actualCasesCmd.ts @@ -227,6 +227,7 @@ export async function actualCasesCmd( warns: boolean | null, mutes: boolean | null, unmutes: boolean | null, + kicks: boolean | null, bans: boolean | null, unbans: boolean | null, reverseFilters: boolean | null, @@ -239,27 +240,30 @@ export async function actualCasesCmd( : null; const modName = modId ? (mod instanceof UnknownUser ? modId : renderUsername(mod!)) : renderUsername(author); + const allTypes = [ + CaseTypes.Note, + CaseTypes.Warn, + CaseTypes.Mute, + CaseTypes.Unmute, + CaseTypes.Kick, + CaseTypes.Ban, + CaseTypes.Unban, + ]; let typesToShow: CaseTypes[] = []; if (notes) typesToShow.push(CaseTypes.Note); if (warns) typesToShow.push(CaseTypes.Warn); if (mutes) typesToShow.push(CaseTypes.Mute); if (unmutes) typesToShow.push(CaseTypes.Unmute); + if (kicks) typesToShow.push(CaseTypes.Kick); if (bans) typesToShow.push(CaseTypes.Ban); if (unbans) typesToShow.push(CaseTypes.Unban); if (typesToShow.length === 0) { - typesToShow = [CaseTypes.Note, CaseTypes.Warn, CaseTypes.Mute, CaseTypes.Unmute, CaseTypes.Ban, CaseTypes.Unban]; + typesToShow = allTypes; } else { if (reverseFilters) { - typesToShow = [ - CaseTypes.Note, - CaseTypes.Warn, - CaseTypes.Mute, - CaseTypes.Unmute, - CaseTypes.Ban, - CaseTypes.Unban, - ].filter((t) => !typesToShow.includes(t)); + typesToShow = allTypes.filter((t) => !typesToShow.includes(t)); } }