头像cmd,.setImage头像不会显示为gif

时间:2020-05-24 19:50:32

标签: javascript discord discord.js gif avatar

j

因此,如您在scrrenshot中看到的那样,链接是.gif,但是(您看不到明显的)“。setImage”不是gif,而是webp,我不知道为什么。

这是我的代码:

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);
        }
    }
};

如果有人知道为什么/有解决办法,那会很好。

1 个答案:

答案 0 :(得分:1)

{ format: "png", dynamic: true }确实无效。动态选项是指如果化身为动画,则变为.gif,否则返回png
因此,如果dynamic选项为true,则无需使用format选项。