Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions interactions/api/http/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,24 +727,22 @@ async def create_auto_moderation_rule(
:return: A dictionary containing the new automod rule.
"""

params = {
payload = {
"name": name,
"event_type": event_type,
"trigger_type": trigger_type,
"actions": actions,
"enabled": enabled,
}
if trigger_metadata:
params["trigger_metadata"] = trigger_metadata
payload["trigger_metadata"] = trigger_metadata
if exempt_roles:
params["exempt_roles"] = exempt_roles
payload["exempt_roles"] = exempt_roles
if exempt_channels:
params["exempt_channels"] = exempt_channels
payload["exempt_channels"] = exempt_channels

return await self._req.request(
Route(
"POST", f"/guilds/{guild_id}/auto-moderation/rules/", params=params, reason=reason
)
Route("POST", f"/guilds/{guild_id}/auto-moderation/rules"), json=payload, reason=reason
)

async def modify_auto_moderation_rule(
Expand Down
21 changes: 18 additions & 3 deletions interactions/api/models/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"AutoModKeywordPresetTypes",
"AutoModTriggerType",
"AutoModMetaData",
"AutoModActionTypes",
"AutoModAction",
"AutoModTriggerMetadata",
"AllowedMentionType",
Expand Down Expand Up @@ -217,6 +218,12 @@ class AutoModKeywordPresetTypes(IntEnum):
SLURS = 3


class AutoModActionTypes(IntEnum):
BLOCK_MESSAGE = 1
SEND_ALERT_MESSAGE = 2
TIMEOUT = 3


@define()
class AutoModAction(DictSerializerMixin):
"""
Expand All @@ -228,11 +235,11 @@ class AutoModAction(DictSerializerMixin):
.. note::
The metadata can be omitted depending on the action type.

:ivar int type: Action type.
:ivar AutoModActionTypes type: Action type.
:ivar AutoModMetaData metadata: Additional metadata needed during execution for this specific action type.
"""

type: int = field()
type: AutoModActionTypes = field(converter=AutoModActionTypes)
metadata: Optional[AutoModMetaData] = field(converter=AutoModMetaData, default=None)


Expand All @@ -242,11 +249,19 @@ class AutoModTriggerMetadata(DictSerializerMixin):
A class object used to represent the trigger metadata from the AutoMod rule object.

:ivar Optional[List[str]] keyword_filter: Words to match against content.
:ivar Optional[List[str]] regex_patterns: Regular expression patterns to match against content.
:ivar Optional[List[str]] presets: The internally pre-defined wordsets which will be searched for in content.
:ivar Optional[List[int]] allow_list: Substrings which will be exempt from triggering the preset trigger type.
:ivar Optional[int] mention_total_limit: Total number of unique role and user mentions allowed per message.
"""

keyword_filter: Optional[List[str]] = field(default=None)
presets: Optional[List[str]] = field(default=None)
regex_patterns: Optional[List[str]] = field(default=None)
presets: Optional[List[AutoModKeywordPresetTypes]] = field(
converter=convert_list(AutoModKeywordPresetTypes), default=None
)
allow_list: Optional[List[int]] = field(default=None)
mention_total_limit: Optional[int] = field(default=None)


class Color(IntEnum):
Expand Down