Add a __eq__ and __ne__ to models Guild and User

This commit is contained in:
A-Trash-Coder
2020-05-20 21:45:46 -04:00
parent 4a2440ea53
commit 857fd4c4ad
2 changed files with 12 additions and 0 deletions

View File

@@ -78,6 +78,12 @@ class User(DiscordModelsBase):
def __str__(self):
return f"{self.name}#{self.discriminator}"
def __eq__(self, user):
return isinstance(user, User) and user.id == self.id
def __ne__(self, user):
return not self.__eq__(user)
@property
def name(self):
"""An alias to the username attribute."""