From c9627e9219f378ef872c6d84ed87467602f57b02 Mon Sep 17 00:00:00 2001 From: metal Date: Tue, 14 Sep 2021 15:43:15 +0000 Subject: [PATCH] prettier and rmv debugging --- .../plugins/Automod/events/runAutomodOnThreadEvents.ts | 6 +++--- backend/src/plugins/Automod/triggers/threadArchive.ts | 4 +--- backend/src/plugins/Automod/triggers/threadUnarchive.ts | 8 +++----- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/backend/src/plugins/Automod/events/runAutomodOnThreadEvents.ts b/backend/src/plugins/Automod/events/runAutomodOnThreadEvents.ts index d64900bb..97d19403 100644 --- a/backend/src/plugins/Automod/events/runAutomodOnThreadEvents.ts +++ b/backend/src/plugins/Automod/events/runAutomodOnThreadEvents.ts @@ -23,10 +23,10 @@ export const RunAutomodOnThreadCreate = typedGuildEventListener c.id === thread.parentId); + const sourceChannel = thread.parent ?? pluginData.client.channels.cache.find(c => c.id === thread.parentId); if (sourceChannel?.isText()) { const sourceMessage = sourceChannel.messages.cache.find( - (m) => m.thread?.id === thread.id || m.reference?.channelId === thread.id, + m => m.thread?.id === thread.id || m.reference?.channelId === thread.id, ); if (sourceMessage) { const savedMessage = pluginData.state.savedMessages.msgToSavedMessage(sourceMessage); @@ -86,7 +86,7 @@ export const RunAutomodOnThreadUpdate = typedGuildEventListener()({ } const thread = context.threadChange.archived; - console.log("matching thread_archive"); if (typeof triggerConfig.locked === "boolean" && thread.locked !== triggerConfig.locked) { return; } - console.log("locked pass"); if (triggerConfig.parent) { const parentIds = Array.isArray(triggerConfig.parent) ? triggerConfig.parent : [triggerConfig.parent]; if (thread.parentId && !parentIds.includes(thread.parentId)) return; } - console.log("parent pass"); + return { extra: { matchedThreadId: thread.id, diff --git a/backend/src/plugins/Automod/triggers/threadUnarchive.ts b/backend/src/plugins/Automod/triggers/threadUnarchive.ts index 8af0d0d7..b2669ab8 100644 --- a/backend/src/plugins/Automod/triggers/threadUnarchive.ts +++ b/backend/src/plugins/Automod/triggers/threadUnarchive.ts @@ -25,14 +25,12 @@ export const ThreadUnarchiveTrigger = automodTrigger()({ return; } - if (triggerConfig.locked && !context.threadChange.locked) { - return; - } else if (triggerConfig.locked === false && !context.threadChange.unlocked) { + const thread = context.threadChange.unarchived; + + if (typeof triggerConfig.locked === "boolean" && thread.locked !== triggerConfig.locked) { return; } - const thread = context.threadChange.unarchived; - if (triggerConfig.parent) { const parentIds = Array.isArray(triggerConfig.parent) ? triggerConfig.parent : [triggerConfig.parent]; if (thread.parentId && !parentIds.includes(thread.parentId)) return;