Search code examples
javascriptdiscorddiscord.jsgifavatar

avatar cmd, .setImage avatar isn't displayed as a gif


j

So as you can see in the scrrenshot the link is a .gif but (you cannot see that obvious) the ".setImage" isn't a gif, it is a webp and i wonder why.

Here's my code:

module.exports = {
    name: 'avatar',
    aliases: ['ava', 'profilepic', 'profilepicture'],
    description: 'Displays your own avatar or the avatar of a user you emntioned',
    category: "general",
    usage: 'prefix | avatar | mention',
    run : async (message, client, args) => {
        const Discord = require('discord.js');

        if (!message.mentions.users.size) {
            let embed1 = new Discord.MessageEmbed()
                .setColor(color)
                .setTitle(`Your avatar`)
                .setImage(message.author.displayAvatarURL({ format: "png", dynamic: true }))
                .addField(`Link:`, `${message.author.displayAvatarURL({ format: "png", dynamic: true })}`)
            message.channel.send(embed1);
        }
        else{
            const user = message.mentions.users.first()
            let embed2 = new Discord.MessageEmbed()
                .setColor(color)
                .setTitle(`${user.username}'s avatar:`)
                .setImage(user.displayAvatarURL({ format: "png", dynamic: true }))
                .addField(`Link:`, `${user.displayAvatarURL({ format: "png", dynamic: true })}`)
            message.channel.send(embed2);
        }
    }
};

Would be nice if someone knows why/has a solution.


Solution

  • { format: "png", dynamic: true } doesn't really work. Dynamic option means turned into .gif if the avatar is animated, else turns back with png.
    So you don't need to use format option if dynamic option is true.