Avatar handling with png, not jpg

This commit is contained in:
Jeremy Zhang 2018-02-17 04:27:21 +00:00
parent 076870763e
commit ff401271e6
2 changed files with 4 additions and 4 deletions

View File

@ -168,7 +168,7 @@ class Gateway(Namespace):
usr["avatar"] = member.avatar usr["avatar"] = member.avatar
usr["color"] = self.get_user_color(guild_id, usr["id"]) usr["color"] = self.get_user_color(guild_id, usr["id"])
if (usr["avatar"]): if (usr["avatar"]):
usr["avatar_url"] = "https://cdn.discordapp.com/avatars/{}/{}.jpg".format(usr["id"], usr["avatar"]) usr["avatar_url"] = "https://cdn.discordapp.com/avatars/{}/{}.png".format(usr["id"], usr["avatar"])
usr["roles"] = json.loads(member.roles) usr["roles"] = json.loads(member.roles)
usr["stargazer"] = "star" in get_badges(member.user_id) usr["stargazer"] = "star" in get_badges(member.user_id)
else: else:
@ -180,7 +180,7 @@ class Gateway(Namespace):
usr["avatar"] = member.avatar usr["avatar"] = member.avatar
usr["color"] = self.get_user_color(guild_id, usr["id"]) usr["color"] = self.get_user_color(guild_id, usr["id"])
if (usr["avatar"]): if (usr["avatar"]):
usr["avatar_url"] = "https://cdn.discordapp.com/avatars/{}/{}.jpg".format(usr["id"], usr["avatar"]) usr["avatar_url"] = "https://cdn.discordapp.com/avatars/{}/{}.png".format(usr["id"], usr["avatar"])
usr["roles"] = json.loads(member.roles) usr["roles"] = json.loads(member.roles)
usr["stargazer"] = "star" in get_badges(member.user_id) usr["stargazer"] = "star" in get_badges(member.user_id)
emit("lookup_user_info", usr) emit("lookup_user_info", usr)

View File

@ -97,14 +97,14 @@ def check_user_permission(guild_id, id):
def generate_avatar_url(id, av, discrim="0000"): def generate_avatar_url(id, av, discrim="0000"):
if av: if av:
return avatar_base_url + str(id) + '/' + str(av) + '.jpg' return avatar_base_url + str(id) + '/' + str(av) + '.png'
else: else:
default_av = [0, 1, 2, 3, 4] default_av = [0, 1, 2, 3, 4]
discrim = int(discrim) discrim = int(discrim)
return "https://cdn.discordapp.com/embed/avatars/{}.png".format(default_av[int(discrim) % len(default_av)]) return "https://cdn.discordapp.com/embed/avatars/{}.png".format(default_av[int(discrim) % len(default_av)])
def generate_guild_icon_url(id, hash): def generate_guild_icon_url(id, hash):
return guild_icon_url + str(id) + "/" + str(hash) + ".jpg" return guild_icon_url + str(id) + "/" + str(hash) + ".png"
def generate_bot_invite_url(guild_id): def generate_bot_invite_url(guild_id):
url = "https://discordapp.com/oauth2/authorize?&client_id={}&scope=bot&permissions={}&guild_id={}".format(config['client-id'], '641195117', guild_id) url = "https://discordapp.com/oauth2/authorize?&client_id={}&scope=bot&permissions={}&guild_id={}".format(config['client-id'], '641195117', guild_id)