aboutsummaryrefslogtreecommitdiff
path: root/discord/emoji.py
diff options
context:
space:
mode:
authorGorialis <[email protected]>2018-01-02 07:59:51 +0900
committerRapptz <[email protected]>2018-01-06 17:32:25 -0500
commit04d9dd9c0dc82b4d870c6269ecc3a9e46cd7292e (patch)
tree4f3060a57302181cf9287786be2655aad5f985a0 /discord/emoji.py
parentAdd intersphinx (diff)
downloaddiscord.py-04d9dd9c0dc82b4d870c6269ecc3a9e46cd7292e.tar.xz
discord.py-04d9dd9c0dc82b4d870c6269ecc3a9e46cd7292e.zip
Change PartialReactionEmoji to PartialEmoji, add a PartialEmojiConverter
Diffstat (limited to 'discord/emoji.py')
-rw-r--r--discord/emoji.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/discord/emoji.py b/discord/emoji.py
index a04a2ad5..82a4a69a 100644
--- a/discord/emoji.py
+++ b/discord/emoji.py
@@ -30,8 +30,8 @@ from collections import namedtuple
from . import utils
from .mixins import Hashable
-class PartialReactionEmoji(namedtuple('PartialReactionEmoji', 'name id')):
- """Represents a "partial" reaction emoji.
+class PartialEmoji(namedtuple('PartialEmoji', 'animated name id')):
+ """Represents a "partial" emoji.
This model will be given in two scenarios:
@@ -61,6 +61,8 @@ class PartialReactionEmoji(namedtuple('PartialReactionEmoji', 'name id')):
name: :class:`str`
The custom emoji name, if applicable, or the unicode codepoint
of the non-custom emoji.
+ animated: :class:`bool`
+ Whether the emoji is animated or not.
id: Optional[:class:`int`]
The ID of the custom emoji, if applicable.
"""
@@ -70,7 +72,7 @@ class PartialReactionEmoji(namedtuple('PartialReactionEmoji', 'name id')):
def __str__(self):
if self.id is None:
return self.name
- return '<:%s:%s>' % (self.name, self.id)
+ return '<%s:%s:%s>' % ('a' if self.animated else '', self.name, self.id)
def is_custom_emoji(self):
"""Checks if this is a custom non-Unicode emoji."""
@@ -85,6 +87,15 @@ class PartialReactionEmoji(namedtuple('PartialReactionEmoji', 'name id')):
return self.name
return ':%s:%s' % (self.name, self.id)
+ @property
+ def url(self):
+ """Returns a URL version of the emoji, if it is custom."""
+ if self.is_unicode_emoji():
+ return None
+
+ _format = 'gif' if self.animated else 'png'
+ return "https://cdn.discordapp.com/emojis/{0.id}.{1}".format(self, _format)
+
class Emoji(Hashable):
"""Represents a custom emoji.