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