From ac3eb74500155fd6c882db22a182cf23ed8ae4dc Mon Sep 17 00:00:00 2001 From: iamshoXy Date: Sat, 29 Jul 2023 15:07:33 +0200 Subject: [PATCH] add default option --- .../plugins/ModActions/ModActionsPlugin.ts | 1 + .../plugins/ModActions/functions/banUserId.ts | 2 +- backend/src/plugins/ModActions/types.ts | 43 ++++++++++--------- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/backend/src/plugins/ModActions/ModActionsPlugin.ts b/backend/src/plugins/ModActions/ModActionsPlugin.ts index bf83b13e..523a48d3 100644 --- a/backend/src/plugins/ModActions/ModActionsPlugin.ts +++ b/backend/src/plugins/ModActions/ModActionsPlugin.ts @@ -62,6 +62,7 @@ const defaultOptions = { kick_message: "You have been kicked from the {guildName} server. Reason given: {reason}", ban_message: "You have been banned from the {guildName} server. Reason given: {reason}", tempban_message: "You have been banned from the {guildName} server for {banTime}. Reason given: {reason}", + default_ban_reason: "No reason specified", alert_on_rejoin: false, alert_channel: null, warn_notify_enabled: false, diff --git a/backend/src/plugins/ModActions/functions/banUserId.ts b/backend/src/plugins/ModActions/functions/banUserId.ts index e4191a6c..1fb3ba5e 100644 --- a/backend/src/plugins/ModActions/functions/banUserId.ts +++ b/backend/src/plugins/ModActions/functions/banUserId.ts @@ -42,7 +42,7 @@ export async function banUserId( }; } - reason = reason || "No reason specified"; + reason = reason || (config.default_ban_reason || "No reason specified"); // Attempt to message the user *before* banning them, as doing it after may not be possible const member = await resolveMember(pluginData.client, pluginData.guild, userId); diff --git a/backend/src/plugins/ModActions/types.ts b/backend/src/plugins/ModActions/types.ts index 447b9638..4bcb6a02 100644 --- a/backend/src/plugins/ModActions/types.ts +++ b/backend/src/plugins/ModActions/types.ts @@ -23,6 +23,7 @@ export const ConfigSchema = t.type({ kick_message: tNullable(t.string), ban_message: tNullable(t.string), tempban_message: tNullable(t.string), + default_ban_reason: tNullable(t.string), alert_on_rejoin: t.boolean, alert_channel: tNullable(t.string), warn_notify_enabled: t.boolean, @@ -91,36 +92,36 @@ export interface IIgnoredEvent { export type WarnResult = | { - status: "failed"; - error: string; - } + status: "failed"; + error: string; + } | { - status: "success"; - case: Case; - notifyResult: UserNotificationResult; - }; + status: "success"; + case: Case; + notifyResult: UserNotificationResult; + }; export type KickResult = | { - status: "failed"; - error: string; - } + status: "failed"; + error: string; + } | { - status: "success"; - case: Case; - notifyResult: UserNotificationResult; - }; + status: "success"; + case: Case; + notifyResult: UserNotificationResult; + }; export type BanResult = | { - status: "failed"; - error: string; - } + status: "failed"; + error: string; + } | { - status: "success"; - case: Case; - notifyResult: UserNotificationResult; - }; + status: "success"; + case: Case; + notifyResult: UserNotificationResult; + }; export type WarnMemberNotifyRetryCallback = () => boolean | Promise;