所以,正如你在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);
}
}
};
如果有人知道为什么会有解决办法就好了.
{ format: "png", dynamic: true }
并没有真正的工作。动态选项意味着变成了 .gif
如果头像是动画的,否则就会回身用 png
. 所以如果动态选项为真,你就不需要使用格式选项。