From b2755a754b1b36478f24a5316db901924a3ebd4f Mon Sep 17 00:00:00 2001 From: metal Date: Tue, 14 Sep 2021 15:37:45 +0000 Subject: [PATCH] check props on run loop --- backend/src/plugins/Automod/actions/archiveThread.ts | 5 +++-- backend/src/plugins/Automod/actions/unArchiveThread.ts | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/backend/src/plugins/Automod/actions/archiveThread.ts b/backend/src/plugins/Automod/actions/archiveThread.ts index b5d771e3..1a5a32ed 100644 --- a/backend/src/plugins/Automod/actions/archiveThread.ts +++ b/backend/src/plugins/Automod/actions/archiveThread.ts @@ -15,12 +15,13 @@ export const ArchiveThreadAction = automodAction({ const threads = contexts .filter((c) => c.message?.channel_id) .map((c) => pluginData.guild.channels.cache.get(c.message!.channel_id)) - .filter((c): c is ThreadChannel => (c?.isThread() && !c.archived) ?? false); + .filter((c): c is ThreadChannel => c?.isThread() ?? false); for (const thread of threads) { - if (actionConfig.lock) { + if (actionConfig.lock && !thread.locked) { await thread.setLocked().catch(noop); } + if (thread.archived) continue; await thread.setArchived().catch(noop); } }, diff --git a/backend/src/plugins/Automod/actions/unArchiveThread.ts b/backend/src/plugins/Automod/actions/unArchiveThread.ts index cdd17d74..ceedcd6d 100644 --- a/backend/src/plugins/Automod/actions/unArchiveThread.ts +++ b/backend/src/plugins/Automod/actions/unArchiveThread.ts @@ -15,12 +15,13 @@ export const UnArchiveThreadAction = automodAction({ const threads = contexts .filter((c) => c.message?.channel_id) .map((c) => pluginData.guild.channels.cache.get(c.message!.channel_id)) - .filter((c): c is ThreadChannel => (c?.isThread() && c.archived) ?? false); + .filter((c): c is ThreadChannel => c?.isThread() ?? false); for (const thread of threads) { - if (actionConfig.unlock) { + if (actionConfig.unlock && thread.locked) { await thread.setLocked(false).catch(noop); } + if (!thread.archived) continue; await thread.setArchived(false).catch(noop); } },