From d2d7166e6692b6af8d6b37629c3e4bfe7e7f6183 Mon Sep 17 00:00:00 2001 From: Andrei Date: Wed, 11 Jan 2017 21:09:57 -0600 Subject: [PATCH] add User.get_avatar_url to support more formats/sizes --- disco/types/user.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/disco/types/user.py b/disco/types/user.py index b04c180..d4c32cd 100644 --- a/disco/types/user.py +++ b/disco/types/user.py @@ -14,14 +14,20 @@ class User(SlottedModel, with_equality('id'), with_hash('id')): presence = Field(None) - @property - def avatar_url(self): + def get_avatar_url(self, fmt='webp', size=1024): if not self.avatar: return None - return 'https://discordapp.com/api/users/{}/avatars/{}.jpg'.format( + return 'https://cdn.discordapp.com/avatars/{}/{}.{}?size={}'.format( self.id, - self.avatar) + self.avatar, + fmt, + size + ) + + @property + def avatar_url(self): + return self.get_avatar_url() @property def mention(self):