Add int() and str() support to Message

This commit is contained in:
Arthur Jovart 2021-08-29 01:09:05 +02:00
parent fa7f8efc8e
commit 22de755059
No known key found for this signature in database
GPG Key ID: DE4444AAAAAAAAAA

View File

@ -503,6 +503,14 @@ class Message(Hashable):
Returns the message's hash.
.. describe:: str(x)
Returns the message's content.
.. describe:: int(x)
Returns the message's ID.
Attributes
-----------
tts: :class:`bool`
@ -712,6 +720,12 @@ 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
def _try_patch(self, data, key, transform=None) -> None:
try:
value = data[key]