diff options
| author | Ben Mintz <[email protected]> | 2018-11-15 12:06:35 -0600 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2019-01-28 22:22:48 -0500 |
| commit | ce3ede1551c8e8a748bd79bfe415a1333a1b7a73 (patch) | |
| tree | 096f08d6885182cfbc4de68f3635e111dcb642af | |
| parent | Fix user/user_id documentation for reaction remove events (diff) | |
| download | discord.py-ce3ede1551c8e8a748bd79bfe415a1333a1b7a73.tar.xz discord.py-ce3ede1551c8e8a748bd79bfe415a1333a1b7a73.zip | |
Implement PartialEmoji == Emoji (fixes #1627)
| -rw-r--r-- | discord/emoji.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/discord/emoji.py b/discord/emoji.py index 46abcdcf..101c861e 100644 --- a/discord/emoji.py +++ b/discord/emoji.py @@ -75,6 +75,13 @@ class PartialEmoji(namedtuple('PartialEmoji', 'animated name id')): return '<a:%s:%s>' % (self.name, self.id) return '<:%s:%s>' % (self.name, self.id) + def __eq__(self, other): + if self.is_unicode_emoji(): + return isinstance(other, PartialEmoji) and self.name == other.name + + if isinstance(other, (PartialEmoji, Emoji)): + return self.id == other.id + def is_custom_emoji(self): """Checks if this is a custom non-Unicode emoji.""" return self.id is not None @@ -174,6 +181,9 @@ class Emoji(Hashable): def __repr__(self): return '<Emoji id={0.id} name={0.name!r}>'.format(self) + def __eq__(self, other): + return isinstance(other, (PartialEmoji, Emoji)) and self.id == other.id + @property def created_at(self): """Returns the emoji's creation time in UTC.""" |