Error fetching avatar

I included the code and console log below discord.js version 14.15.2
21 Replies
d.js toolkit
d.js toolkit7mo 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!
chewie
chewie7mo ago
log the error?
๖ۣۜKoneko-chan❤
Error fetching avatar for koneko_chann (705648196428496970): Unsupported image type
chewie
chewie7mo ago
Again, log the error, not your own error message
๖ۣۜKoneko-chan❤
umm how do i log it
chewie
chewie7mo ago
console.error(e)
TÆMBØ
TÆMBØ7mo ago
You're leaving out important information when you're only providing the error message and nothing else Given that you're also using canvas in that try block, the error may be originating from canvas and not via fetching the image buffer itself As a separate FYI, the MessageAttachment class was renamed in v14 to Attachment builder - not sure if you selected the wrong version tag or simply used the wrong import
d.js docs
d.js docs7mo ago
:class: AttachmentBuilder @14.15.2 Represents an attachment builder
๖ۣۜKoneko-chan❤
hmm I want the code to take all member's avatar in a server and draw it in a photo like this
No description
TÆMBØ
TÆMBØ7mo ago
And on that note, you can pass a buffer directly as the first parameter of it, which negates the need to write the image to a file, only for it to be read by d.js internally immediately after
chewie
chewie7mo ago
And I'm once again asking you to log the whole error
๖ۣۜKoneko-chan❤
im sorry im new idk how to log it
chewie
chewie7mo ago
I literally told you
TÆMBØ
TÆMBØ7mo ago
:IRT_This:
chewie
chewie7mo ago
chances are the avatar url ends in webp and canvas doesn't like that you can force the avatar url to be returned in png (and force it static if its a gif)
๖ۣۜKoneko-chan❤
I'll try
TÆMBØ
TÆMBØ7mo ago
Which I guess is a good segue to also mention that the option for avatarURL() to set the image type was also renamed from format to extension in v14
d.js docs
d.js docs7mo ago
:method: User#avatarURL @14.15.2 A link to the user's avatar.
chewie
chewie7mo ago
also a good segue to also mention that you should use displayAvatarURL() instead, otherwise you have to expect avatarURL() to return null if the user doesn't have an avatar
TÆMBØ
TÆMBØ7mo ago
(Though user seems to be a GuildMember in this case, it still functions the same)
Want results from more Discord servers?
Add your server