Skip to content

Commit 70f5110

Browse files
authored
feat: implement new automod features (#1372)
* feat: add missing enums * feat: implement new rules and triggers * style: remove redundant ellipsis Signed-off-by: LordOfPolls <ddavidallen13@gmail.com> --------- Signed-off-by: LordOfPolls <ddavidallen13@gmail.com>
1 parent edab1b4 commit 70f5110

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

interactions/models/discord/auto_mod.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ class HarmfulLinkFilter(BaseTrigger):
121121
repr=True,
122122
metadata=docs("The type of trigger"),
123123
)
124-
...
125124

126125

127126
@attrs.define(eq=False, order=False, hash=False, kw_only=True)
@@ -151,12 +150,24 @@ class MentionSpamTrigger(BaseTrigger):
151150
)
152151

153152

153+
@attrs.define(eq=False, order=False, hash=False, kw_only=True)
154+
class MemberProfileTrigger(BaseTrigger):
155+
regex_patterns: list[str] = attrs.field(
156+
factory=list, repr=True, metadata=docs("The regex patterns to check against")
157+
)
158+
keyword_filter: str | list[str] = attrs.field(
159+
factory=list, repr=True, metadata=docs("The keywords to check against")
160+
)
161+
allow_list: list["Snowflake_Type"] = attrs.field(
162+
factory=list, repr=True, metadata=docs("The roles exempt from this rule")
163+
)
164+
165+
154166
@attrs.define(eq=False, order=False, hash=False, kw_only=True)
155167
class BlockMessage(BaseAction):
156168
"""blocks the content of a message according to the rule"""
157169

158170
type: AutoModAction = attrs.field(repr=False, default=AutoModAction.BLOCK_MESSAGE, converter=AutoModAction)
159-
...
160171

161172

162173
@attrs.define(eq=False, order=False, hash=False, kw_only=True)
@@ -175,6 +186,13 @@ class TimeoutUser(BaseAction):
175186
type: AutoModAction = attrs.field(repr=False, default=AutoModAction.TIMEOUT_USER, converter=AutoModAction)
176187

177188

189+
@attrs.define(eq=False, order=False, hash=False, kw_only=False)
190+
class BlockMemberInteraction(BaseAction):
191+
"""Block a member from using text, voice, or other interactions"""
192+
193+
# this action has no metadata
194+
195+
178196
@attrs.define(eq=False, order=False, hash=False, kw_only=True)
179197
class AutoModRule(DiscordObject):
180198
"""A representation of an auto mod rule"""
@@ -345,11 +363,13 @@ def member(self) -> "Optional[Member]":
345363
AutoModAction.BLOCK_MESSAGE: BlockMessage,
346364
AutoModAction.ALERT_MESSAGE: AlertMessage,
347365
AutoModAction.TIMEOUT_USER: TimeoutUser,
366+
AutoModAction.BLOCK_MEMBER_INTERACTION: BlockMemberInteraction,
348367
}
349368

350369
TRIGGER_MAPPING = {
351370
AutoModTriggerType.KEYWORD: KeywordTrigger,
352371
AutoModTriggerType.HARMFUL_LINK: HarmfulLinkFilter,
353372
AutoModTriggerType.KEYWORD_PRESET: KeywordPresetTrigger,
354373
AutoModTriggerType.MENTION_SPAM: MentionSpamTrigger,
374+
AutoModTriggerType.MEMBER_PROFILE: MemberProfileTrigger,
355375
}

interactions/models/discord/enums.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,16 +974,19 @@ class AutoModTriggerType(CursedIntEnum):
974974
SPAM = 3
975975
KEYWORD_PRESET = 4
976976
MENTION_SPAM = 5
977+
MEMBER_PROFILE = 6
977978

978979

979980
class AutoModAction(CursedIntEnum):
980981
BLOCK_MESSAGE = 1
981982
ALERT_MESSAGE = 2
982983
TIMEOUT_USER = 3
984+
BLOCK_MEMBER_INTERACTION = 4
983985

984986

985987
class AutoModEvent(CursedIntEnum):
986988
MESSAGE_SEND = 1
989+
MEMBER_UPDATE = 2
987990

988991

989992
class AutoModLanuguageType(Enum):

0 commit comments

Comments
 (0)