aboutsummaryrefslogtreecommitdiff
path: root/discord/emoji.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2017-06-09 18:36:59 -0400
committerRapptz <[email protected]>2017-06-09 18:36:59 -0400
commitd239cc26666ff255a0c86c83541ef90f2b586598 (patch)
treef7c644f297190cede85b324bdb1d776543523a1e /discord/emoji.py
parentAllow sending files list smaller than 2 elements in Messageable.send (diff)
downloaddiscord.py-d239cc26666ff255a0c86c83541ef90f2b586598.tar.xz
discord.py-d239cc26666ff255a0c86c83541ef90f2b586598.zip
Implement "partial" message events.
These are events that get triggered regardless of the state of the message cache. Useful for getting data from before the bot was booted.
Diffstat (limited to 'discord/emoji.py')
-rw-r--r--discord/emoji.py50
1 files changed, 49 insertions, 1 deletions
diff --git a/discord/emoji.py b/discord/emoji.py
index 8c880b5d..0c161c6c 100644
--- a/discord/emoji.py
+++ b/discord/emoji.py
@@ -30,7 +30,55 @@ from collections import namedtuple
from . import utils
from .mixins import Hashable
-PartialEmoji = namedtuple('PartialEmoji', 'id name')
+class PartialReactionEmoji(namedtuple('PartialReactionEmoji', 'name id')):
+ """Represents a "partial" reaction emoji.
+
+ This model will be given in two scenarios:
+
+ - "Raw" data events such as :func:`on_raw_reaction_add`
+ - Custom emoji that the bot cannot see from e.g. :attr:`Message.reactions`
+
+ .. container:: operations
+
+ .. describe:: x == y
+
+ Checks if two emoji are the same.
+
+ .. describe:: x != y
+
+ Checks if two emoji are not the same.
+
+ .. describe:: hash(x)
+
+ Return the emoji's hash.
+
+ .. describe:: str(x)
+
+ Returns the emoji rendered for discord.
+
+ Attributes
+ -----------
+ name: str
+ The custom emoji name, if applicable, or the unicode codepoint
+ of the non-custom emoji.
+ id: Optional[int]
+ The ID of the custom emoji, if applicable.
+ """
+
+ __slots__ = ()
+
+ def __str__(self):
+ if self.id is None:
+ return self.name
+ return '<:%s:%s>' % (self.name, self.id)
+
+ def is_custom_emoji(self):
+ """Checks if this is a custom non-Unicode emoji."""
+ return self.id is not None
+
+ def is_unicode_emoji(self):
+ """Checks if this is a Unicode emoji."""
+ return self.id is None
class Emoji(Hashable):
"""Represents a custom emoji.