Fix Emoji.__hash__ being None.
When a type defines __eq__, Python removes its __hash__ function. Fixes #1933
This commit is contained in:
parent
11a0098269
commit
bbc4460c38
@ -27,7 +27,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
from collections import namedtuple
|
||||
|
||||
from . import utils
|
||||
from .mixins import Hashable
|
||||
|
||||
class PartialEmoji(namedtuple('PartialEmoji', 'animated name id')):
|
||||
"""Represents a "partial" emoji.
|
||||
@ -104,7 +103,7 @@ class PartialEmoji(namedtuple('PartialEmoji', 'animated name id')):
|
||||
_format = 'gif' if self.animated else 'png'
|
||||
return "https://cdn.discordapp.com/emojis/{0.id}.{1}".format(self, _format)
|
||||
|
||||
class Emoji(Hashable):
|
||||
class Emoji:
|
||||
"""Represents a custom emoji.
|
||||
|
||||
Depending on the way this object was created, some of the attributes can
|
||||
@ -184,6 +183,9 @@ class Emoji(Hashable):
|
||||
def __eq__(self, other):
|
||||
return isinstance(other, (PartialEmoji, Emoji)) and self.id == other.id
|
||||
|
||||
def __hash__(self):
|
||||
return self.id >> 22
|
||||
|
||||
@property
|
||||
def created_at(self):
|
||||
"""Returns the emoji's creation time in UTC."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user