Add __int__ special method to User and Member

This commit is contained in:
Arthur Jovart
2021-08-29 00:59:29 +02:00
parent 6bcc717e63
commit 31e3e99c2b
2 changed files with 14 additions and 0 deletions

View File

@@ -96,6 +96,9 @@ class BaseUser(_UserTag):
def __str__(self) -> str:
return f'{self.name}#{self.discriminator}'
def __int__(self) -> int:
return self.id
def __eq__(self, other: Any) -> bool:
return isinstance(other, _UserTag) and other.id == self.id
@@ -415,6 +418,10 @@ class User(BaseUser, discord.abc.Messageable):
Returns the user's name with discriminator.
.. describe:: int(x)
Returns the user's ID.
Attributes
-----------
name: :class:`str`