mirror of
https://github.com/keanuplayz/dotfiles.git
synced 2024-08-15 02:33:12 +00:00
[scripts/discord-whois] fix a crash on users with the default avatar
This commit is contained in:
parent
11e651e1cb
commit
ed7835b342
1 changed files with 11 additions and 9 deletions
|
@ -62,18 +62,20 @@ def bool_to_yes_no(value):
|
||||||
|
|
||||||
print_field("ID", data["id"])
|
print_field("ID", data["id"])
|
||||||
print_field("Name", "{}#{}".format(data["username"], data["discriminator"]))
|
print_field("Name", "{}#{}".format(data["username"], data["discriminator"]))
|
||||||
print_field(
|
|
||||||
"Avatar",
|
default_avatar_url = "https://cdn.discordapp.com/embed/avatars/{}.png".format(
|
||||||
|
int(data["discriminator"], 10) % 5
|
||||||
|
)
|
||||||
|
avatar_url = (
|
||||||
"https://cdn.discordapp.com/avatars/{}/{}.{}".format(
|
"https://cdn.discordapp.com/avatars/{}/{}.{}".format(
|
||||||
data["id"], data["avatar"], "gif" if data["avatar"].startswith("a_") else "png"
|
data["id"], data["avatar"], "gif" if data["avatar"].startswith("a_") else "png"
|
||||||
),
|
)
|
||||||
)
|
if data["avatar"] is not None
|
||||||
print_field(
|
else default_avatar_url
|
||||||
"Default avatar",
|
|
||||||
"https://cdn.discordapp.com/embed/avatars/{}.png".format(
|
|
||||||
int(data["discriminator"], 10) % 5
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
print_field("Avatar", avatar_url)
|
||||||
|
print_field("Default avatar", default_avatar_url)
|
||||||
print_field("Bot", bool_to_yes_no(data.get("bot", False)))
|
print_field("Bot", bool_to_yes_no(data.get("bot", False)))
|
||||||
print_field("System user", bool_to_yes_no(data.get("system", False)))
|
print_field("System user", bool_to_yes_no(data.get("system", False)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue