From 723995f30cea824c1c0d0ea6627a4b6d1061c7c8 Mon Sep 17 00:00:00 2001 From: almeidx Date: Sun, 29 Aug 2021 15:30:36 +0100 Subject: [PATCH] added parent info in the matchSummary --- .../src/plugins/Automod/triggers/threadCreate.ts | 13 +++++++++---- .../src/plugins/Automod/triggers/threadDelete.ts | 15 +++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/backend/src/plugins/Automod/triggers/threadCreate.ts b/backend/src/plugins/Automod/triggers/threadCreate.ts index c72da089..e95d5bd2 100644 --- a/backend/src/plugins/Automod/triggers/threadCreate.ts +++ b/backend/src/plugins/Automod/triggers/threadCreate.ts @@ -7,6 +7,8 @@ import { automodTrigger } from "../helpers"; interface ThreadCreateResult { matchedThreadId: Snowflake; matchedThreadName: string; + matchedThreadParentId: Snowflake; + matchedThreadParentName: string; matchedThreadOwner: User | undefined; } @@ -33,6 +35,8 @@ export const ThreadCreateTrigger = automodTrigger()({ extra: { matchedThreadId: thread.id, matchedThreadName: thread.name, + matchedThreadParentId: thread.parentId ?? "Unknown", + matchedThreadParentName: thread.parent?.name ?? "Unknown", matchedThreadOwner: context.user, }, }; @@ -42,11 +46,12 @@ export const ThreadCreateTrigger = automodTrigger()({ const threadId = matchResult.extra.matchedThreadId; const threadName = matchResult.extra.matchedThreadName; const threadOwner = matchResult.extra.matchedThreadOwner; + const parentId = matchResult.extra.matchedThreadParentId; + const parentName = matchResult.extra.matchedThreadParentName; + const base = `Thread **#${threadName}** (\`${threadId}\`) has been created in the **#${parentName}** (\`${parentId}\`) channel`; if (threadOwner) { - return `Thread **#${Util.escapeBold(threadName)}** (\`${threadId}\`) has been created by **${ - threadOwner.tag - }** (\`${threadOwner.id}\`)`; + return `${base} by **${Util.escapeBold(threadOwner.tag)}** (\`${threadOwner.id}\`)`; } - return `Thread **#${Util.escapeBold(threadName)}** (\`${threadId}\`) has been created`; + return base; }, }); diff --git a/backend/src/plugins/Automod/triggers/threadDelete.ts b/backend/src/plugins/Automod/triggers/threadDelete.ts index f8d65a4a..1a22fdd5 100644 --- a/backend/src/plugins/Automod/triggers/threadDelete.ts +++ b/backend/src/plugins/Automod/triggers/threadDelete.ts @@ -7,6 +7,8 @@ import { automodTrigger } from "../helpers"; interface ThreadDeleteResult { matchedThreadId: Snowflake; matchedThreadName: string; + matchedThreadParentId: Snowflake; + matchedThreadParentName: string; matchedThreadOwner: User | undefined; } @@ -33,6 +35,8 @@ export const ThreadDeleteTrigger = automodTrigger()({ extra: { matchedThreadId: thread.id, matchedThreadName: thread.name, + matchedThreadParentId: thread.parentId ?? "Unknown", + matchedThreadParentName: thread.parent?.name ?? "Unknown", matchedThreadOwner: context.user, }, }; @@ -40,13 +44,16 @@ export const ThreadDeleteTrigger = automodTrigger()({ renderMatchInformation({ matchResult }) { const threadId = matchResult.extra.matchedThreadId; - const threadName = matchResult.extra.matchedThreadName; const threadOwner = matchResult.extra.matchedThreadOwner; + const threadName = matchResult.extra.matchedThreadName; + const parentId = matchResult.extra.matchedThreadParentId; + const parentName = matchResult.extra.matchedThreadParentName; if (threadOwner) { - return `Thread **${Util.escapeBold(threadName ?? "Unknown")}** (\`${threadId}\`) created by **${Util.escapeBold( + return `Thread **#${threadName ?? "Unknown"}** (\`${threadId}\`) created by **${Util.escapeBold( threadOwner.tag, - )}** (\`${threadOwner.id}\`) has been deleted`; + )}** (\`${threadOwner.id}\`) in the **#${parentName}** (\`${parentId}\`) channel has been deleted`; } - return `Thread **${Util.escapeBold(threadName ?? "Unknown")}** (\`${threadId}\`) has been deleted`; + return `Thread **#${threadName ?? + "Unknown"}** (\`${threadId}\`) from the **#${parentName}** (\`${parentId}\`) channel has been deleted`; }, });