#Getting user's avatar

1 messages · Page 1 of 1 (latest)

hasty vortex
#

How would I get the Discord author URL for a member? I saw a previous thread which showed it in the format

format!("https://cdn.discordapp.com/avatars/{}/{}.png", message.author.id, message.author.avatar

but what do I do if message.author.avatar is None? Is there not a way to know which default avatar Discord associated with that user?

#

discord.js has something like .displayAvatarURL for this

#

Seems like the default avatar is just the user's discriminator % 5 popped into https://cdn.discordapp.com/embed/avatars/${discriminator}.png

edit: not quite sure how that works tho, because there is https://cdn.discordapp.com/embed/avatars/5.png, don't think i've seen anyone with that avatar tho?

weary blaze
#

That's what I was going to mention to use, it's not five though

hasty vortex
weary blaze
#

It's the user's discriminator Arithmetic remainder 5

#

as part of an operation

#

like

#

format!("https://cdn.discordapp.com/embed/avatars/{}.png", discriminator % 5)

hasty vortex
#

oh right yeah that's what I meant haha

#

Is that URL I linked of 5.png an easter egg then?

weary blaze
#

must be lol

hasty vortex
#

I've never seen anyone with that default pfp

#

cheers for the help @weary blaze

weary blaze
hasty vortex
#

Right

#

It would normally be 0-4 with remainder