Browse Source

adds support for animated emoji

pull/74/head
Sebastian Winkler 8 years ago
parent
commit
ed122c4bea
No known key found for this signature in database GPG Key ID: 6E5F12DD21107C1D
  1. 7
      disco/types/guild.py
  2. 3
      disco/types/message.py

7
disco/types/guild.py

@ -54,6 +54,8 @@ class GuildEmoji(Emoji):
Whether this emoji is managed by an integration.
roles : list(snowflake)
Roles this emoji is attached to.
animated : bool
Whether this emoji is animated.
"""
id = Field(snowflake)
guild_id = Field(snowflake)
@ -61,8 +63,11 @@ class GuildEmoji(Emoji):
require_colons = Field(bool)
managed = Field(bool)
roles = ListField(snowflake)
animated = Field(bool)
def __str__(self):
if self.animated:
return u'<a:{}:{}>'.format(self.name, self.id)
return u'<:{}:{}>'.format(self.name, self.id)
def update(self, **kwargs):
@ -73,6 +78,8 @@ class GuildEmoji(Emoji):
@property
def url(self):
if self.animated:
return 'https://discordapp.com/api/emojis/{}.gif'.format(self.id)
return 'https://discordapp.com/api/emojis/{}.png'.format(self.id)
@cached_property

3
disco/types/message.py

@ -37,9 +37,12 @@ class Emoji(SlottedModel):
The emoji ID (will be none if this is not a custom emoji).
name : str
The name of this emoji.
animated : bool
Whether this emoji is animated.
"""
id = Field(snowflake)
name = Field(text)
animated = Field(bool)
@cached_property
def custom(self):

Loading…
Cancel
Save