From ce3ede1551c8e8a748bd79bfe415a1333a1b7a73 Mon Sep 17 00:00:00 2001 From: Ben Mintz Date: Thu, 15 Nov 2018 12:06:35 -0600 Subject: [PATCH] Implement PartialEmoji == Emoji (fixes #1627) --- discord/emoji.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/discord/emoji.py b/discord/emoji.py index 46abcdcfe..101c861e5 100644 --- a/discord/emoji.py +++ b/discord/emoji.py @@ -75,6 +75,13 @@ class PartialEmoji(namedtuple('PartialEmoji', 'animated name id')): return '' % (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 ''.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."""