Skip to content
This repository has been archived by the owner on Aug 1, 2021. It is now read-only.

Commit

Permalink
adds support for animated emoji (#74)
Browse files Browse the repository at this point in the history
* adds support for animated emoji

* improves string creation
  • Loading branch information
Seklfreak authored and b1naryth1ef committed Jan 10, 2018
1 parent c8d6cb0 commit a8ebb0f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions disco/types/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,19 @@ 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)
name = Field(text)
require_colons = Field(bool)
managed = Field(bool)
roles = ListField(snowflake)
animated = Field(bool)

def __str__(self):
return u'<:{}:{}>'.format(self.name, self.id)
return u'<{}:{}:{}>'.format('a' if self.animated else '', self.name, self.id)

def update(self, **kwargs):
return self.client.api.guilds_emojis_modify(self.guild_id, self.id, **kwargs)
Expand All @@ -73,7 +76,7 @@ def delete(self, **kwargs):

@property
def url(self):
return 'https://discordapp.com/api/emojis/{}.png'.format(self.id)
return 'https://discordapp.com/api/emojis/{}.{}'.format(self.id, 'gif' if self.animated else 'png')

@cached_property
def guild(self):
Expand Down
3 changes: 3 additions & 0 deletions disco/types/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit a8ebb0f

Please sign in to comment.