Add int() support to Hashable, making it available across the board for AuditLogEntry, *Channel, Guild, Object, Message, ...

This commit is contained in:
Arthur Jovart
2021-08-29 01:21:20 +02:00
parent 22de755059
commit 64ee792391
13 changed files with 79 additions and 5 deletions

View File

@ -125,6 +125,10 @@ class Attachment(Hashable):
Returns the hash of the attachment.
.. describe:: int(x)
Returns the attachment's ID.
.. versionchanged:: 1.7
Attachment can now be casted to :class:`str` and is hashable.
@ -720,8 +724,6 @@ class Message(Hashable):
f'<{name} id={self.id} channel={self.channel!r} type={self.type!r} author={self.author!r} flags={self.flags!r}>'
)
def __int__(self) -> int:
return self.id
def __str__(self) -> Optional[str]:
return self.content
@ -1639,6 +1641,10 @@ class PartialMessage(Hashable):
Returns the partial message's hash.
.. describe:: int(x)
Returns the partial message's ID.
Attributes
-----------
channel: Union[:class:`TextChannel`, :class:`Thread`, :class:`DMChannel`]