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
- 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 OPnode 22.14.0
discord.js 14.17.3
i'm not sure if this is related to discord.js
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?documentation suggestion for @Thiago - Csync:
:function: calculateUserDefaultAvatarIndex
[email protected]
Calculates the default avatar index for a given user id.If you're using discord.js, why not just use
User#displayAvatarURL()
instead?This function only returns to members who have already interacted with the application, right?
Members or users?
I'll test it now, I didn't know it existed.
User
Because you can fetch any user on Discord with their ID regardless if they share a guild with your app or not
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.
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
It worked with this function, it's what I needed
But thanks to everyone