From 25a3350196311bc3b286f433643ead9be3a9660f Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Mon, 3 May 2021 18:49:52 +0300 Subject: [PATCH] Add hide_case option to automod mod actions --- backend/src/plugins/Automod/actions/ban.ts | 3 +++ backend/src/plugins/Automod/actions/kick.ts | 3 +++ backend/src/plugins/Automod/actions/mute.ts | 3 +++ backend/src/plugins/Automod/actions/warn.ts | 3 +++ backend/src/plugins/Cases/functions/createCase.ts | 1 + backend/src/plugins/Cases/types.ts | 1 + 6 files changed, 14 insertions(+) diff --git a/backend/src/plugins/Automod/actions/ban.ts b/backend/src/plugins/Automod/actions/ban.ts index ae2f0292..5619cca8 100644 --- a/backend/src/plugins/Automod/actions/ban.ts +++ b/backend/src/plugins/Automod/actions/ban.ts @@ -22,10 +22,12 @@ export const BanAction = automodAction({ notifyChannel: tNullable(t.string), deleteMessageDays: tNullable(t.number), postInCaseLog: tNullable(t.boolean), + hide_case: t.boolean, }), defaultConfig: { notify: null, // Use defaults from ModActions + hide_case: false, }, async apply({ pluginData, contexts, actionConfig, matchResult }) { @@ -39,6 +41,7 @@ export const BanAction = automodAction({ extraNotes: matchResult.fullSummary ? [matchResult.fullSummary] : [], automatic: true, postInCaseLogOverride: actionConfig.postInCaseLog ?? undefined, + hide: actionConfig.hide_case, }; const userIdsToBan = unique(contexts.map(c => c.user?.id).filter(nonNullish)); diff --git a/backend/src/plugins/Automod/actions/kick.ts b/backend/src/plugins/Automod/actions/kick.ts index 9ae01ade..38c6cde1 100644 --- a/backend/src/plugins/Automod/actions/kick.ts +++ b/backend/src/plugins/Automod/actions/kick.ts @@ -12,10 +12,12 @@ export const KickAction = automodAction({ notify: tNullable(t.string), notifyChannel: tNullable(t.string), postInCaseLog: tNullable(t.boolean), + hide_case: t.boolean, }), defaultConfig: { notify: null, // Use defaults from ModActions + hide_case: false, }, async apply({ pluginData, contexts, actionConfig, matchResult }) { @@ -27,6 +29,7 @@ export const KickAction = automodAction({ extraNotes: matchResult.fullSummary ? [matchResult.fullSummary] : [], automatic: true, postInCaseLogOverride: actionConfig.postInCaseLog ?? undefined, + hide: actionConfig.hide_case, }; const userIdsToKick = unique(contexts.map(c => c.user?.id).filter(nonNullish)); diff --git a/backend/src/plugins/Automod/actions/mute.ts b/backend/src/plugins/Automod/actions/mute.ts index c7f0c99c..d5ae8363 100644 --- a/backend/src/plugins/Automod/actions/mute.ts +++ b/backend/src/plugins/Automod/actions/mute.ts @@ -26,10 +26,12 @@ export const MuteAction = automodAction({ remove_roles_on_mute: tNullable(t.union([t.boolean, t.array(t.string)])), restore_roles_on_mute: tNullable(t.union([t.boolean, t.array(t.string)])), postInCaseLog: tNullable(t.boolean), + hide_case: t.boolean, }), defaultConfig: { notify: null, // Use defaults from ModActions + hide_case: false, }, async apply({ pluginData, contexts, actionConfig, ruleName, matchResult }) { @@ -44,6 +46,7 @@ export const MuteAction = automodAction({ extraNotes: matchResult.fullSummary ? [matchResult.fullSummary] : [], automatic: true, postInCaseLogOverride: actionConfig.postInCaseLog ?? undefined, + hide: actionConfig.hide_case, }; const userIdsToMute = unique(contexts.map(c => c.user?.id).filter(nonNullish)); diff --git a/backend/src/plugins/Automod/actions/warn.ts b/backend/src/plugins/Automod/actions/warn.ts index 99d0d602..2aa381fe 100644 --- a/backend/src/plugins/Automod/actions/warn.ts +++ b/backend/src/plugins/Automod/actions/warn.ts @@ -12,10 +12,12 @@ export const WarnAction = automodAction({ notify: tNullable(t.string), notifyChannel: tNullable(t.string), postInCaseLog: tNullable(t.boolean), + hide_case: t.boolean, }), defaultConfig: { notify: null, // Use defaults from ModActions + hide_case: false, }, async apply({ pluginData, contexts, actionConfig, matchResult }) { @@ -27,6 +29,7 @@ export const WarnAction = automodAction({ extraNotes: matchResult.fullSummary ? [matchResult.fullSummary] : [], automatic: true, postInCaseLogOverride: actionConfig.postInCaseLog ?? undefined, + hide: actionConfig.hide_case, }; const userIdsToWarn = unique(contexts.map(c => c.user?.id).filter(nonNullish)); diff --git a/backend/src/plugins/Cases/functions/createCase.ts b/backend/src/plugins/Cases/functions/createCase.ts index 0de3d3b5..fd3caa04 100644 --- a/backend/src/plugins/Cases/functions/createCase.ts +++ b/backend/src/plugins/Cases/functions/createCase.ts @@ -35,6 +35,7 @@ export async function createCase(pluginData: GuildPluginData, a audit_log_id: args.auditLogId, pp_id: args.ppId, pp_name: ppName, + is_hidden: Boolean(args.hide), }); if (args.reason || (args.noteDetails && args.noteDetails.length)) { diff --git a/backend/src/plugins/Cases/types.ts b/backend/src/plugins/Cases/types.ts index 1a00a814..a38414ab 100644 --- a/backend/src/plugins/Cases/types.ts +++ b/backend/src/plugins/Cases/types.ts @@ -40,6 +40,7 @@ export type CaseArgs = { postInCaseLogOverride?: boolean; noteDetails?: string[]; extraNotes?: string[]; + hide?: boolean; }; export type CaseNoteArgs = {