mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 12:18:59 +00:00
Add support for message delete audit log action type.
This commit is contained in:
parent
663315f7ac
commit
86bfcdd129
@ -213,6 +213,13 @@ class AuditLogEntry:
|
|||||||
if self.action is enums.AuditLogAction.member_prune:
|
if self.action is enums.AuditLogAction.member_prune:
|
||||||
# member prune has two keys with useful information
|
# member prune has two keys with useful information
|
||||||
self.extra = type('_AuditLogProxy', (), {k: int(v) for k, v in self.extra.items()})()
|
self.extra = type('_AuditLogProxy', (), {k: int(v) for k, v in self.extra.items()})()
|
||||||
|
elif self.action is enums.AuditLogAction.message_delete:
|
||||||
|
channel_id = int(self.extra['channel_id'])
|
||||||
|
elems = {
|
||||||
|
'count': int(self.extra['count']),
|
||||||
|
'channel': self.guild.get_channel(channel_id) or discord.Object(id=channel_id)
|
||||||
|
}
|
||||||
|
self.extra = type('_AuditLogProxy', (), elems)()
|
||||||
elif self.action.name.startswith('overwrite_'):
|
elif self.action.name.startswith('overwrite_'):
|
||||||
# the overwrite_ actions have a dict with some information
|
# the overwrite_ actions have a dict with some information
|
||||||
instance_id = int(self.extra['id'])
|
instance_id = int(self.extra['id'])
|
||||||
@ -317,3 +324,6 @@ class AuditLogEntry:
|
|||||||
|
|
||||||
def _convert_target_emoji(self, target_id):
|
def _convert_target_emoji(self, target_id):
|
||||||
return self._state.get_emoji(target_id) or Object(id=target_id)
|
return self._state.get_emoji(target_id) or Object(id=target_id)
|
||||||
|
|
||||||
|
def _convert_target_message(self, target_id):
|
||||||
|
return self._get_member(target_id)
|
||||||
|
@ -146,6 +146,7 @@ class AuditLogAction(Enum):
|
|||||||
emoji_create = 60
|
emoji_create = 60
|
||||||
emoji_update = 61
|
emoji_update = 61
|
||||||
emoji_delete = 62
|
emoji_delete = 62
|
||||||
|
message_delete = 72
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def category(self):
|
def category(self):
|
||||||
@ -175,6 +176,7 @@ class AuditLogAction(Enum):
|
|||||||
AuditLogAction.emoji_create: AuditLogActionCategory.create,
|
AuditLogAction.emoji_create: AuditLogActionCategory.create,
|
||||||
AuditLogAction.emoji_update: AuditLogActionCategory.update,
|
AuditLogAction.emoji_update: AuditLogActionCategory.update,
|
||||||
AuditLogAction.emoji_delete: AuditLogActionCategory.delete,
|
AuditLogAction.emoji_delete: AuditLogActionCategory.delete,
|
||||||
|
AuditLogAction.message_delete: AuditLogActionCategory.delete,
|
||||||
}
|
}
|
||||||
return lookup[self]
|
return lookup[self]
|
||||||
|
|
||||||
@ -197,7 +199,8 @@ class AuditLogAction(Enum):
|
|||||||
return 'webhook'
|
return 'webhook'
|
||||||
elif v < 70:
|
elif v < 70:
|
||||||
return 'emoji'
|
return 'emoji'
|
||||||
|
elif v < 80:
|
||||||
|
return 'message'
|
||||||
|
|
||||||
def try_enum(cls, val):
|
def try_enum(cls, val):
|
||||||
"""A function that tries to turn the value into enum ``cls``.
|
"""A function that tries to turn the value into enum ``cls``.
|
||||||
|
15
docs/api.rst
15
docs/api.rst
@ -1082,6 +1082,21 @@ All enumerations are subclasses of `enum`_.
|
|||||||
|
|
||||||
- :attr:`~AuditLogDiff.name`
|
- :attr:`~AuditLogDiff.name`
|
||||||
|
|
||||||
|
.. attribute:: message_delete
|
||||||
|
|
||||||
|
A message was deleted by a moderator. Note that this
|
||||||
|
only triggers if the message was deleted by either bulk delete
|
||||||
|
or deletion by someone other than the author.
|
||||||
|
|
||||||
|
When this is the action, the type of :attr:`~AuditLogEntry.target` is
|
||||||
|
the :class:`Member` or :class:`User` who had their message deleted.
|
||||||
|
|
||||||
|
When this is the action, the type of :attr:`~AuditLogEntry.extra` is
|
||||||
|
set to an unspecified proxy object with two attributes:
|
||||||
|
|
||||||
|
- ``count``: An integer specifying how many messages were deleted.
|
||||||
|
- ``channel``: A :class:`TextChannel` or :class:`Object` with the channel ID where the message got deleted.
|
||||||
|
|
||||||
|
|
||||||
.. class:: AuditLogActionCategory
|
.. class:: AuditLogActionCategory
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user