aboutsummaryrefslogtreecommitdiff
path: root/discord/user.py
diff options
context:
space:
mode:
authorkhazhyk <[email protected]>2018-01-06 01:29:16 -0500
committerkhazhyk <[email protected]>2018-01-06 01:29:16 -0500
commit456390f417e63126b08ac52fa8ee49ca68cefed8 (patch)
treea51d40593ff38ba93b11e276393a1b677b518906 /discord/user.py
parentFix multipart sending for RequestsWebhookAdapter to work. (diff)
downloaddiscord.py-456390f417e63126b08ac52fa8ee49ca68cefed8.tar.xz
discord.py-456390f417e63126b08ac52fa8ee49ca68cefed8.zip
Ensure gif avatar urls end in `.gif`
This is a workaround for discord having trouble animating gifs if the url does not end in exactly `.gif`. Since avatar_url is common for thumbnails etc., adding this workaround here is handy, and likely restores expected behavior (animated avatars animating).
Diffstat (limited to 'discord/user.py')
-rw-r--r--discord/user.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/discord/user.py b/discord/user.py
index b476f4df..ca5b1415 100644
--- a/discord/user.py
+++ b/discord/user.py
@@ -155,7 +155,10 @@ class BaseUser(_BaseUser):
else:
format = static_format
- return 'https://cdn.discordapp.com/avatars/{0.id}/{0.avatar}.{1}?size={2}'.format(self, format, size)
+ # Discord has trouble animating gifs if the url does not end in `.gif`
+ gif_fix = '&_=.gif' if format == 'gif' else ''
+
+ return 'https://cdn.discordapp.com/avatars/{0.id}/{0.avatar}.{1}?size={2}{3}'.format(self, format, size, gif_fix)
@property
def default_avatar(self):