mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 20:28:38 +00:00
Fall back to Object for AuditLogEntry.target
Co-authored-by: zephyrkul <zephyrkul@users.noreply.github.com>
This commit is contained in:
parent
d11c42c2e6
commit
509a5d771f
@ -749,8 +749,8 @@ class AuditLogEntry(Hashable):
|
|||||||
def _convert_target_channel(self, target_id: int) -> Union[abc.GuildChannel, Object]:
|
def _convert_target_channel(self, target_id: int) -> Union[abc.GuildChannel, Object]:
|
||||||
return self.guild.get_channel(target_id) or Object(id=target_id)
|
return self.guild.get_channel(target_id) or Object(id=target_id)
|
||||||
|
|
||||||
def _convert_target_user(self, target_id: int) -> Union[Member, User, None]:
|
def _convert_target_user(self, target_id: int) -> Union[Member, User, Object, None]:
|
||||||
return self._get_member(target_id)
|
return self._get_member(target_id) or Object(id=target_id, type=Member)
|
||||||
|
|
||||||
def _convert_target_role(self, target_id: int) -> Union[Role, Object]:
|
def _convert_target_role(self, target_id: int) -> Union[Role, Object]:
|
||||||
return self.guild.get_role(target_id) or Object(id=target_id, type=Role)
|
return self.guild.get_role(target_id) or Object(id=target_id, type=Role)
|
||||||
@ -779,8 +779,8 @@ class AuditLogEntry(Hashable):
|
|||||||
def _convert_target_emoji(self, target_id: int) -> Union[Emoji, Object]:
|
def _convert_target_emoji(self, target_id: int) -> Union[Emoji, Object]:
|
||||||
return self._state.get_emoji(target_id) or Object(id=target_id, type=Emoji)
|
return self._state.get_emoji(target_id) or Object(id=target_id, type=Emoji)
|
||||||
|
|
||||||
def _convert_target_message(self, target_id: int) -> Union[Member, User, None]:
|
def _convert_target_message(self, target_id: int) -> Union[Member, User, Object, None]:
|
||||||
return self._get_member(target_id)
|
return self._get_member(target_id) or Object(id=target_id, type=Member)
|
||||||
|
|
||||||
def _convert_target_stage_instance(self, target_id: int) -> Union[StageInstance, Object]:
|
def _convert_target_stage_instance(self, target_id: int) -> Union[StageInstance, Object]:
|
||||||
return self.guild.get_stage_instance(target_id) or Object(id=target_id, type=StageInstance)
|
return self.guild.get_stage_instance(target_id) or Object(id=target_id, type=StageInstance)
|
||||||
|
18
docs/api.rst
18
docs/api.rst
@ -2061,7 +2061,7 @@ of :class:`enum.Enum`.
|
|||||||
A member was kicked.
|
A member was kicked.
|
||||||
|
|
||||||
When this is the action, the type of :attr:`~AuditLogEntry.target` is
|
When this is the action, the type of :attr:`~AuditLogEntry.target` is
|
||||||
the :class:`User` who got kicked.
|
the :class:`User` or :class:`Object` who got kicked.
|
||||||
|
|
||||||
When this is the action, :attr:`~AuditLogEntry.changes` is empty.
|
When this is the action, :attr:`~AuditLogEntry.changes` is empty.
|
||||||
|
|
||||||
@ -2085,7 +2085,7 @@ of :class:`enum.Enum`.
|
|||||||
A member was banned.
|
A member was banned.
|
||||||
|
|
||||||
When this is the action, the type of :attr:`~AuditLogEntry.target` is
|
When this is the action, the type of :attr:`~AuditLogEntry.target` is
|
||||||
the :class:`User` who got banned.
|
the :class:`User` or :class:`Object` who got banned.
|
||||||
|
|
||||||
When this is the action, :attr:`~AuditLogEntry.changes` is empty.
|
When this is the action, :attr:`~AuditLogEntry.changes` is empty.
|
||||||
|
|
||||||
@ -2094,7 +2094,7 @@ of :class:`enum.Enum`.
|
|||||||
A member was unbanned.
|
A member was unbanned.
|
||||||
|
|
||||||
When this is the action, the type of :attr:`~AuditLogEntry.target` is
|
When this is the action, the type of :attr:`~AuditLogEntry.target` is
|
||||||
the :class:`User` who got unbanned.
|
the :class:`User` or :class:`Object` who got unbanned.
|
||||||
|
|
||||||
When this is the action, :attr:`~AuditLogEntry.changes` is empty.
|
When this is the action, :attr:`~AuditLogEntry.changes` is empty.
|
||||||
|
|
||||||
@ -2106,7 +2106,7 @@ of :class:`enum.Enum`.
|
|||||||
- They were server muted or deafened (or it was undo'd)
|
- They were server muted or deafened (or it was undo'd)
|
||||||
|
|
||||||
When this is the action, the type of :attr:`~AuditLogEntry.target` is
|
When this is the action, the type of :attr:`~AuditLogEntry.target` is
|
||||||
the :class:`Member` or :class:`User` who got updated.
|
the :class:`Member`, :class:`User`, or :class:`Object` who got updated.
|
||||||
|
|
||||||
Possible attributes for :class:`AuditLogDiff`:
|
Possible attributes for :class:`AuditLogDiff`:
|
||||||
|
|
||||||
@ -2121,7 +2121,7 @@ of :class:`enum.Enum`.
|
|||||||
either gains a role or loses a role.
|
either gains a role or loses a role.
|
||||||
|
|
||||||
When this is the action, the type of :attr:`~AuditLogEntry.target` is
|
When this is the action, the type of :attr:`~AuditLogEntry.target` is
|
||||||
the :class:`Member` or :class:`User` who got the role.
|
the :class:`Member`, :class:`User`, or :class:`Object` who got the role.
|
||||||
|
|
||||||
Possible attributes for :class:`AuditLogDiff`:
|
Possible attributes for :class:`AuditLogDiff`:
|
||||||
|
|
||||||
@ -2157,7 +2157,7 @@ of :class:`enum.Enum`.
|
|||||||
A bot was added to the guild.
|
A bot was added to the guild.
|
||||||
|
|
||||||
When this is the action, the type of :attr:`~AuditLogEntry.target` is
|
When this is the action, the type of :attr:`~AuditLogEntry.target` is
|
||||||
the :class:`Member` or :class:`User` which was added to the guild.
|
the :class:`Member`, :class:`User`, or :class:`Object` which was added to the guild.
|
||||||
|
|
||||||
.. versionadded:: 1.3
|
.. versionadded:: 1.3
|
||||||
|
|
||||||
@ -2338,7 +2338,7 @@ of :class:`enum.Enum`.
|
|||||||
only triggers if the message was deleted by someone other than the author.
|
only triggers if the message was deleted by someone other than the author.
|
||||||
|
|
||||||
When this is the action, the type of :attr:`~AuditLogEntry.target` is
|
When this is the action, the type of :attr:`~AuditLogEntry.target` is
|
||||||
the :class:`Member` or :class:`User` who had their message deleted.
|
the :class:`Member`, :class:`User`, or :class:`Object` who had their message deleted.
|
||||||
|
|
||||||
When this is the action, the type of :attr:`~AuditLogEntry.extra` is
|
When this is the action, the type of :attr:`~AuditLogEntry.extra` is
|
||||||
set to an unspecified proxy object with two attributes:
|
set to an unspecified proxy object with two attributes:
|
||||||
@ -2365,7 +2365,7 @@ of :class:`enum.Enum`.
|
|||||||
A message was pinned in a channel.
|
A message was pinned in a channel.
|
||||||
|
|
||||||
When this is the action, the type of :attr:`~AuditLogEntry.target` is
|
When this is the action, the type of :attr:`~AuditLogEntry.target` is
|
||||||
the :class:`Member` or :class:`User` who had their message pinned.
|
the :class:`Member`, :class:`User`, or :class:`Object` who had their message pinned.
|
||||||
|
|
||||||
When this is the action, the type of :attr:`~AuditLogEntry.extra` is
|
When this is the action, the type of :attr:`~AuditLogEntry.extra` is
|
||||||
set to an unspecified proxy object with two attributes:
|
set to an unspecified proxy object with two attributes:
|
||||||
@ -2380,7 +2380,7 @@ of :class:`enum.Enum`.
|
|||||||
A message was unpinned in a channel.
|
A message was unpinned in a channel.
|
||||||
|
|
||||||
When this is the action, the type of :attr:`~AuditLogEntry.target` is
|
When this is the action, the type of :attr:`~AuditLogEntry.target` is
|
||||||
the :class:`Member` or :class:`User` who had their message unpinned.
|
the :class:`Member`, :class:`User`, or :class:`Object` who had their message unpinned.
|
||||||
|
|
||||||
When this is the action, the type of :attr:`~AuditLogEntry.extra` is
|
When this is the action, the type of :attr:`~AuditLogEntry.extra` is
|
||||||
set to an unspecified proxy object with two attributes:
|
set to an unspecified proxy object with two attributes:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user