mirror of
https://github.com/yawaflua/Flask-Discord.git
synced 2025-12-10 12:29:30 +02:00
Add a __eq__ and __ne__ to models Guild and User
This commit is contained in:
@@ -35,6 +35,12 @@ class Guild(DiscordModelsBase):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
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
|
@property
|
||||||
def icon_url(self):
|
def icon_url(self):
|
||||||
"""A property returning direct URL to the guild's icon. Returns None if guild has no icon set."""
|
"""A property returning direct URL to the guild's icon. Returns None if guild has no icon set."""
|
||||||
|
|||||||
@@ -78,6 +78,12 @@ class User(DiscordModelsBase):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.name}#{self.discriminator}"
|
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
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""An alias to the username attribute."""
|
"""An alias to the username attribute."""
|
||||||
|
|||||||
Reference in New Issue
Block a user