From 72798fbdd2cc7bc92e737cb31fd04a4c0792269a Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 28 Aug 2022 16:08:05 +1000 Subject: [PATCH] Add additional audit log types for automod --- discord/audit_logs.py | 6 +++++- discord/enums.py | 6 +++++- docs/api.rst | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/discord/audit_logs.py b/discord/audit_logs.py index 52b82a667..7b1359e79 100644 --- a/discord/audit_logs.py +++ b/discord/audit_logs.py @@ -538,7 +538,11 @@ class AuditLogEntry(Hashable): channel=self.guild.get_channel_or_thread(channel_id) or Object(id=channel_id), message_id=int(extra['message_id']), ) - elif self.action is enums.AuditLogAction.automod_block_message: + elif ( + self.action is enums.AuditLogAction.automod_block_message + or self.action is enums.AuditLogAction.automod_flag_message + or self.action is enums.AuditLogAction.automod_timeout_member + ): channel_id = int(extra['channel_id']) self.extra = _AuditLogProxyAutoModAction( automod_rule_name=extra['auto_moderation_rule_name'], diff --git a/discord/enums.py b/discord/enums.py index 21aa1f582..5e9489ea0 100644 --- a/discord/enums.py +++ b/discord/enums.py @@ -510,6 +510,8 @@ class AuditLogAction(Enum): automod_rule_update = 141 automod_rule_delete = 142 automod_block_message = 143 + automod_flag_message = 144 + automod_timeout_member = 145 # fmt: on @property @@ -568,6 +570,8 @@ class AuditLogAction(Enum): AuditLogAction.automod_rule_update: AuditLogActionCategory.update, AuditLogAction.automod_rule_delete: AuditLogActionCategory.delete, AuditLogAction.automod_block_message: None, + AuditLogAction.automod_flag_message: None, + AuditLogAction.automod_timeout_member: None, } # fmt: on return lookup[self] @@ -609,7 +613,7 @@ class AuditLogAction(Enum): return 'integration_or_app_command' elif v < 143: return 'auto_moderation' - elif v == 143: + elif v < 146: return 'user' diff --git a/docs/api.rst b/docs/api.rst index 7d00caf01..6cbef0896 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -2837,6 +2837,42 @@ of :class:`enum.Enum`. .. versionadded:: 2.0 + .. attribute:: automod_flag_message + + An automod rule flagged a message. + + When this is the action, the type of :attr:`~AuditLogEntry.target` is + a :class:`Member` with the ID of the person who triggered the automod rule. + + When this is the action, the type of :attr:`~AuditLogEntry.extra` is + set to an unspecified proxy object with 3 attributes: + + - ``automod_rule_name``: The name of the automod rule that was triggered. + - ``automod_rule_trigger``: A :class:`AutoModRuleTriggerType` representation of the rule type that was triggered. + - ``channel``: The channel in which the automod rule was triggered. + + When this is the action, :attr:`AuditLogEntry.changes` is empty. + + .. versionadded:: 2.1 + + .. attribute:: automod_timeout_member + + An automod rule timed-out a member. + + When this is the action, the type of :attr:`~AuditLogEntry.target` is + a :class:`Member` with the ID of the person who triggered the automod rule. + + When this is the action, the type of :attr:`~AuditLogEntry.extra` is + set to an unspecified proxy object with 3 attributes: + + - ``automod_rule_name``: The name of the automod rule that was triggered. + - ``automod_rule_trigger``: A :class:`AutoModRuleTriggerType` representation of the rule type that was triggered. + - ``channel``: The channel in which the automod rule was triggered. + + When this is the action, :attr:`AuditLogEntry.changes` is empty. + + .. versionadded:: 2.1 + .. class:: AuditLogActionCategory Represents the category that the :class:`AuditLogAction` belongs to.