Return default avatar URL if an avatar is not given for User.avatar_url
Also use the CDN URL like Jake has always requested.
This commit is contained in:
parent
63604e0566
commit
36a5925908
@ -120,12 +120,15 @@ class User(discord.abc.Messageable):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def avatar_url(self):
|
def avatar_url(self):
|
||||||
"""Returns a friendly URL version of the avatar variable the user has. An empty string if
|
"""Returns a friendly URL version of the avatar the user has.
|
||||||
the user has no avatar."""
|
|
||||||
if self.avatar is None:
|
|
||||||
return ''
|
|
||||||
|
|
||||||
url = 'https://images.discordapp.net/avatars/{0.id}/{0.avatar}.{1}?size=1024'
|
If the user does not have a traditional avatar, their default
|
||||||
|
avatar URL is returned instead.
|
||||||
|
"""
|
||||||
|
if self.avatar is None:
|
||||||
|
return self.default_avatar_url
|
||||||
|
|
||||||
|
url = 'https://cdn.discordapp.com/avatars/{0.id}/{0.avatar}.{1}?size=1024'
|
||||||
if self.avatar.startswith('a_'):
|
if self.avatar.startswith('a_'):
|
||||||
return url.format(self, 'gif')
|
return url.format(self, 'gif')
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user