diff --git a/backend/src/plugins/Automod/actions/clean.ts b/backend/src/plugins/Automod/actions/clean.ts index 1bebe626..2e2b55ab 100644 --- a/backend/src/plugins/Automod/actions/clean.ts +++ b/backend/src/plugins/Automod/actions/clean.ts @@ -6,7 +6,7 @@ export const CleanAction = automodAction({ configType: t.boolean, defaultConfig: false, - async apply({ pluginData, contexts }) { + async apply({ pluginData, contexts, ruleName }) { const messageIdsToDeleteByChannelId: Map = new Map(); for (const context of contexts) { if (context.message) { @@ -14,6 +14,11 @@ export const CleanAction = automodAction({ messageIdsToDeleteByChannelId.set(context.message.channel_id, []); } + if (messageIdsToDeleteByChannelId.get(context.message.channel_id).includes(context.message.id)) { + console.warn(`Message ID to delete was already present: ${pluginData.guild.name}, rule ${ruleName}`); + continue; + } + messageIdsToDeleteByChannelId.get(context.message.channel_id).push(context.message.id); } }