Browse Source

Add additional audit log types for automod

pull/10109/head
Josh 3 years ago
committed by dolfies
parent
commit
72798fbdd2
  1. 6
      discord/audit_logs.py
  2. 6
      discord/enums.py
  3. 36
      docs/api.rst

6
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'],

6
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'

36
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.

Loading…
Cancel
Save