diff options
| author | Rapptz <[email protected]> | 2017-01-09 03:41:01 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2017-01-09 03:41:01 -0500 |
| commit | 36a59259084fbfb44050c8c0119f45d956d8c972 (patch) | |
| tree | e5b398ec9880e2d9a26c6b789ee5ae06249101ac | |
| parent | Use CDN URL for default avatars. (diff) | |
| download | discord.py-36a59259084fbfb44050c8c0119f45d956d8c972.tar.xz discord.py-36a59259084fbfb44050c8c0119f45d956d8c972.zip | |
Return default avatar URL if an avatar is not given for User.avatar_url
Also use the CDN URL like Jake has always requested.
| -rw-r--r-- | discord/user.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/discord/user.py b/discord/user.py index 0a959438..c3c0d9c2 100644 --- a/discord/user.py +++ b/discord/user.py @@ -120,12 +120,15 @@ class User(discord.abc.Messageable): @property def avatar_url(self): - """Returns a friendly URL version of the avatar variable the user has. An empty string if - the user has no avatar.""" + """Returns a friendly URL version of the avatar the user has. + + If the user does not have a traditional avatar, their default + avatar URL is returned instead. + """ if self.avatar is None: - return '' + return self.default_avatar_url - url = 'https://images.discordapp.net/avatars/{0.id}/{0.avatar}.{1}?size=1024' + url = 'https://cdn.discordapp.com/avatars/{0.id}/{0.avatar}.{1}?size=1024' if self.avatar.startswith('a_'): return url.format(self, 'gif') else: |