mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-12-25 06:27:03 +01:00
Handle default avatars
This commit is contained in:
parent
12f2acd0c8
commit
cb05b44100
@ -44,7 +44,7 @@ def callback():
|
|||||||
session['user_id'] = user['id']
|
session['user_id'] = user['id']
|
||||||
session['username'] = user['username']
|
session['username'] = user['username']
|
||||||
session['discriminator'] = user['discriminator']
|
session['discriminator'] = user['discriminator']
|
||||||
session['avatar'] = generate_avatar_url(user['id'], user['avatar'])
|
session['avatar'] = generate_avatar_url(user['id'], user['avatar'], user['discriminator'])
|
||||||
session["tokens"] = get_titan_token(session["user_id"])
|
session["tokens"] = get_titan_token(session["user_id"])
|
||||||
if session["tokens"] == -1:
|
if session["tokens"] == -1:
|
||||||
session["tokens"] = 0
|
session["tokens"] = 0
|
||||||
|
@ -89,8 +89,13 @@ def check_user_permission(guild_id, id):
|
|||||||
return user_has_permission(guild['permissions'], id) or guild['owner']
|
return user_has_permission(guild['permissions'], id) or guild['owner']
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def generate_avatar_url(id, av):
|
def generate_avatar_url(id, av, discrim="0000"):
|
||||||
|
if av:
|
||||||
return avatar_base_url + str(id) + '/' + str(av) + '.jpg'
|
return avatar_base_url + str(id) + '/' + str(av) + '.jpg'
|
||||||
|
else:
|
||||||
|
default_av = [0, 1, 2, 3, 4]
|
||||||
|
discrim = int(discrim)
|
||||||
|
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) + ".jpg"
|
||||||
|
Loading…
Reference in New Issue
Block a user