From 36a59259084fbfb44050c8c0119f45d956d8c972 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Mon, 9 Jan 2017 03:41:01 -0500 Subject: [PATCH] Return default avatar URL if an avatar is not given for User.avatar_url Also use the CDN URL like Jake has always requested. --- discord/user.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/discord/user.py b/discord/user.py index 0a959438c..c3c0d9c21 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.""" - if self.avatar is None: - return '' + """Returns a friendly URL version of the avatar the user has. - 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_'): return url.format(self, 'gif') else: