diff --git a/flask_discord/models/guild.py b/flask_discord/models/guild.py index 6069baf..2ba5b21 100644 --- a/flask_discord/models/guild.py +++ b/flask_discord/models/guild.py @@ -6,6 +6,15 @@ from .. import configs class Guild(DiscordModelsBase): """Class representing discord Guild the user is part of. + Operations + ---------- + x == y + Checks if two guild's are the same. + x != y + Checks if two guild's are not the same. + str(x) + Returns the guild's name. + Attributes ---------- id : int @@ -35,6 +44,12 @@ class Guild(DiscordModelsBase): def __str__(self): return self.name + def __eq__(self, guild): + return isinstance(guild, Guild) and guild.id == self.id + + def __ne__(self, guild): + return not self.__eq__(guild) + @property def icon_url(self): """A property returning direct URL to the guild's icon. Returns None if guild has no icon set.""" diff --git a/flask_discord/models/user.py b/flask_discord/models/user.py index 0d67362..34def4f 100644 --- a/flask_discord/models/user.py +++ b/flask_discord/models/user.py @@ -9,6 +9,16 @@ from .connections import UserConnection class User(DiscordModelsBase): """Class representing Discord User. + + Operations + ---------- + x == y + Checks if two user's are the same. + x != y + Checks if two user's are not the same. + str(x) + Returns the user's name with discriminator. + Attributes ---------- id : int @@ -78,6 +88,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."""