From 604ab73fcef6e41c9f31f2755455ff3befe2530a Mon Sep 17 00:00:00 2001 From: Dooley_labs Date: Mon, 29 Oct 2018 18:36:56 -0400 Subject: [PATCH] Add gif integration to get_avatar_url (#113) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update user.py Add proper gif integration to get_avatar_url * Update user.py Undid removal of size and webp * Update user.py This should keep everyone happy... hopefully 🤔 * Update user.py Code cleanup as per z64 --- disco/types/user.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/disco/types/user.py b/disco/types/user.py index 0eeca8d..63e9542 100644 --- a/disco/types/user.py +++ b/disco/types/user.py @@ -22,16 +22,15 @@ class User(SlottedModel, with_equality('id'), with_hash('id')): presence = Field(None) - def get_avatar_url(self, fmt='webp', size=1024): + def get_avatar_url(self, fmt=None, size=1024): if not self.avatar: return 'https://cdn.discordapp.com/embed/avatars/{}.png'.format(self.default_avatar.value) - - return 'https://cdn.discordapp.com/avatars/{}/{}.{}?size={}'.format( - self.id, - self.avatar, - fmt, - size, - ) + if fmt is not None: + return 'https://cdn.discordapp.com/avatars/{}/{}.{}?size={}'.format(self.id, self.avatar, fmt, size) + if self.avatar.startswith('a_'): + return 'https://cdn.discordapp.com/avatars/{}/{}.gif?size={}'.format(self.id, self.avatar, size) + else: + return 'https://cdn.discordapp.com/avatars/{}/{}.webp?size={}'.format(self.id, self.avatar, size) @property def default_avatar(self):