From 47a8452582a9b6839af0dbae8d33ec3ad7ceb215 Mon Sep 17 00:00:00 2001 From: almeidx Date: Tue, 7 Sep 2021 17:29:18 +0100 Subject: [PATCH] clean up --- .../plugins/Automod/triggers/matchMentions.ts | 28 ++++++------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/backend/src/plugins/Automod/triggers/matchMentions.ts b/backend/src/plugins/Automod/triggers/matchMentions.ts index 689fa0818..bd2bf7e15 100644 --- a/backend/src/plugins/Automod/triggers/matchMentions.ts +++ b/backend/src/plugins/Automod/triggers/matchMentions.ts @@ -1,4 +1,3 @@ -import { Role, User } from "discord.js"; import * as t from "io-ts"; import { tNullable } from "../../../utils"; import { getTextMatchPartialSummary } from "../functions/getTextMatchPartialSummary"; @@ -8,6 +7,13 @@ interface MatchResultType { reason: "everyone" | "repliedUser" | "users" | "roles"; } +const summaryType: Record = { + everyone: "everyone", + repliedUser: "replied user", + users: "user", + roles: "role", +}; + export const MatchMentionsTrigger = automodTrigger()({ configType: t.type({ everyone: tNullable(t.boolean), @@ -24,9 +30,7 @@ export const MatchMentionsTrigger = automodTrigger()({ }, async match({ pluginData, context, triggerConfig }) { - if (!context.message) { - return; - } + if (!context.message) return; const channel = pluginData.client.channels.resolve(context.message.channel_id); if (!channel || !channel?.isText()) return; @@ -82,20 +86,6 @@ export const MatchMentionsTrigger = automodTrigger()({ renderMatchInformation({ pluginData, contexts, matchResult }) { const partialSummary = getTextMatchPartialSummary(pluginData, "message", contexts[0]); - - if (matchResult.extra.reason === "everyone") { - return `Matched everyone mention in ${partialSummary}`; - } - if (matchResult.extra.reason === "repliedUser") { - return `Matched reply mention in ${partialSummary}`; - } - if (matchResult.extra.reason === "users") { - return `Matched user mention in ${partialSummary}`; - } - if (matchResult.extra.reason === "roles") { - return `Matched role mention in ${partialSummary}`; - } - - return `Matched mention in ${partialSummary}`; + return `Matched ${summaryType[matchResult.extra.reason]} mention in ${partialSummary}`; }, });