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); } },