aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2022-06-28 12:52:20 +0100
committerGravatar Chris Lovering <[email protected]>2022-06-28 13:04:02 +0100
commit8fc03c3f94683fb6a212148c8cc8e60ed59e70fc (patch)
tree6453cb4fe41dcb7afe3b325a4e32cbfdd79dbdd6
parentBump botcore to get latest d.py changes (diff)
Ignore auto_moderation_action messages when applying anti-spam rules
When a message triggers an auto_moderation_action notification, Discord re-writes the author field for the system message to look as if it's from the original author. This means those messages counted towards our anti-spam filter. This both triggered the filter too early, and also resulted in those auto mod messages being deleted when the filter was hit.
-rw-r--r--bot/exts/filters/antispam.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/bot/exts/filters/antispam.py b/bot/exts/filters/antispam.py
index 9ebf0268d..3b925bacd 100644
--- a/bot/exts/filters/antispam.py
+++ b/bot/exts/filters/antispam.py
@@ -9,7 +9,7 @@ from typing import Dict, Iterable, List, Set
import arrow
from botcore.utils import scheduling
-from discord import Colour, Member, Message, NotFound, Object, TextChannel
+from discord import Colour, Member, Message, MessageType, NotFound, Object, TextChannel
from discord.ext.commands import Cog
from bot import rules
@@ -169,6 +169,7 @@ class AntiSpam(Cog):
or (getattr(message.channel, "category", None) and message.channel.category.name == JAM_CATEGORY_NAME)
or (message.channel.id in Filter.channel_whitelist and not DEBUG_MODE)
or (any(role.id in Filter.role_whitelist for role in message.author.roles) and not DEBUG_MODE)
+ or message.type == MessageType.auto_moderation_action
):
return