aboutsummaryrefslogtreecommitdiff
path: root/discord/asset.py
diff options
context:
space:
mode:
authorDaggy1234 <[email protected]>2020-12-18 08:50:00 +0530
committerGitHub <[email protected]>2020-12-17 22:20:00 -0500
commit13bba3afc228ae3e01a3890cff223202721c0447 (patch)
tree71ed7d52f0a194316713ee37ff36d4e2f82ca623 /discord/asset.py
parent[tasks] Fix a typo in documentation (diff)
downloaddiscord.py-13bba3afc228ae3e01a3890cff223202721c0447.tar.xz
discord.py-13bba3afc228ae3e01a3890cff223202721c0447.zip
Add Emoji.url_as
Diffstat (limited to 'discord/asset.py')
-rw-r--r--discord/asset.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/discord/asset.py b/discord/asset.py
index bf8d8f9d..29a86769 100644
--- a/discord/asset.py
+++ b/discord/asset.py
@@ -153,6 +153,19 @@ class Asset:
return cls(state, '/stickers/{0.id}/{0.image}.png?size={2}'.format(sticker, format, size))
+ @classmethod
+ def _from_emoji(cls, state, emoji, *, format=None, static_format='png'):
+ if format is not None and format not in VALID_AVATAR_FORMATS:
+ raise InvalidArgument("format must be None or one of {}".format(VALID_AVATAR_FORMATS))
+ if format == "gif" and not emoji.animated:
+ raise InvalidArgument("non animated emoji's do not support gif format")
+ if static_format not in VALID_STATIC_FORMATS:
+ raise InvalidArgument("static_format must be one of {}".format(VALID_STATIC_FORMATS))
+ if format is None:
+ format = 'gif' if emoji.animated else static_format
+
+ return cls(state, '/emojis/{0.id}.{1}'.format(emoji, format))
+
def __str__(self):
return self.BASE + self._url if self._url is not None else ''