Error: Unsupported MIME type: image/webp

Trying to do image manipulation with peoples avatars but it's throwing this when a static image of someones avatar is being displayed. When someone has a GIF as their avatar, it comes up but it's as a static image instead of actually a GIF.
const avatar = !member ? interaction.user.avatarURL() : member.avatarURL();
const user = !member ? interaction.user : member;
const avatar = !member ? interaction.user.avatarURL() : member.avatarURL();
const user = !member ? interaction.user : member;
8 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
AJ
AJOP2y ago
Here's an example of a /avatar blur subcommand.
case `blur` : {
const image = await new DIG.Blur().getImage(avatar);
const attach = new AttachmentBuilder(image).setName(`blur.png`);
const embed = new EmbedBuilder()
.setTitle(user.tag)
.setImage(`attachment://blur.png`)
.setColor(settings.embed_colour);
return editReply({ embeds: [embed], files: [ attach ] }).catch(console.error);
}
case `blur` : {
const image = await new DIG.Blur().getImage(avatar);
const attach = new AttachmentBuilder(image).setName(`blur.png`);
const embed = new EmbedBuilder()
.setTitle(user.tag)
.setImage(`attachment://blur.png`)
.setColor(settings.embed_colour);
return editReply({ embeds: [embed], files: [ attach ] }).catch(console.error);
}
DIG is :
const DIG = require(`discord-image-generation`);
const DIG = require(`discord-image-generation`);
tl dr - how does one grab someones gif/image avatar ping me pls when you respond
Squid
Squid2y ago
Your initial code for getting avatar urls is fine If the problem is specific to the file type of the avatars, you can pass in { extension: 'png' } into avatarURL() to force the extension to be a png, or you can also provide jpg/webp/gif extensions if those work
AJ
AJOP2y ago
Thanks - Ideally i'd like to accept jpg/png/gif at once, is this possible?
Squid
Squid2y ago
By default, that's what the method does I assujme the actual problem stems from your DIG package, but I don't know enough about how it works to provide a better solution
AJ
AJOP2y ago
It's the webp file that it's having issues with, how would I force it to only use png/jpg/gif? it usually happens with static avatars if that's not possible, I guess I could try converting it from webp
Squid
Squid2y ago
It looks like if you specify gif, it won't work with people who have nonanimated avatars Specifying just png or just jpg should work fine for everyone, assuming you're ok with animated avatars becoming static
AJ
AJOP2y ago
Not really Just searched around and it seems the package just isn't compatible with gif's thanks for your help
Want results from more Discord servers?
Add your server