我有一个有关从提到的用户添加avatarUrl的问题。我已经完成了代码,但是在发送嵌入文件时没有显示图像。控制台中也没有错误。
const user = message.mentions.users.first();
var mention = "<@" + user.id + ">"
var userCreated = user.createdAt.toString().split(" ");
var userJoined = user.userJoined
const Embed = new Discord.MessageEmbed()
.setTitle(user.tag)
.setDescription(mention)
.setColor("#b60303")
.addFields(
{ name: "Registered at", value: userCreated[1] + " " + userCreated[2] + ", " + userCreated[3]},
{ name: "ID", value: user.id, inline: true}
)
.setImage(message.avatarURL)
.setTimestamp()
.setFooter("ID: " + user.id)
message.channel.send(Embed)
}```
答案 0 :(得分:1)
消息没有头像URL,在Discord JS v12中,avatarURL
是一种方法。
.setImage(message.author.avatarURL())