Problem getting null image

The API route https://discord.com/api/v10/users/@me, when it returns null avatar, how can I know which of the 5 default images discord set for the user? I have already tried to do the calculation, but I was unsuccessful, the result returns 3 for example, when the image is 5.
13 Replies
d.js toolkit
d.js toolkit2w ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Thiago - Csync
Thiago - CsyncOP2w ago
node 22.14.0 discord.js 14.17.3
skyhan
skyhan2w ago
i'm not sure if this is related to discord.js
Булочка | pasha_boez
I have already tried to do the calculation, but I was unsuccessful, the result returns 3 for example, when the image is 5.
Do you try calculateUserDefaultAvatarIndex function?
d.js docs
d.js docs2w ago
documentation suggestion for @Thiago - Csync: :function: calculateUserDefaultAvatarIndex [email protected] Calculates the default avatar index for a given user id.
TÆMBØ
TÆMBØ2w ago
If you're using discord.js, why not just use User#displayAvatarURL() instead?
Thiago - Csync
Thiago - CsyncOP2w ago
This function only returns to members who have already interacted with the application, right?
TÆMBØ
TÆMBØ2w ago
Members or users?
Thiago - Csync
Thiago - CsyncOP2w ago
I'll test it now, I didn't know it existed. User
TÆMBØ
TÆMBØ2w ago
Because you can fetch any user on Discord with their ID regardless if they share a guild with your app or not
Thiago - Csync
Thiago - CsyncOP2w ago
But from what I've read elsewhere, isn't it just users who are in the cache? In addition to those who have already interacted with the application.
Amgelo
Amgelo2w ago
fetching queries discord if they aren't in the cache there's no restrictions to which users you can fetch and structures related to that user usually have the user itself inside them either way, eg Message#user
Thiago - Csync
Thiago - CsyncOP2w ago
It worked with this function, it's what I needed But thanks to everyone

Did you find this page helpful?