如何使它在discord.js的嵌入式消息中显示图片?

时间:2019-10-04 15:04:14

标签: javascript discord.js

我一直在尝试执行.avatar命令,但是每当我输入.avatar时,它都会显示嵌入的消息,但是它不显示图片,而是仅显示URL。如何使它显示图片?'

let avatarEmbed = new Discord.RichEmbed()
  .setDescription(message.author.username)
  .addField("Avatar", message.author.avatarURL)

return message.reply(avatarEmbed)

1 个答案:

答案 0 :(得分:0)

使用RichEmbed.setImage()来设置丰富嵌入的图像。

此外,我总是建议使用User.displayAvatarURL而不是User.avatarURL;当用户没有头像并在某些情况下引起问题时,后者将为undefined,而前者将返回实际显示的默认头像。

let avatarEmbed = new Discord.RichEmbed()
  .setImage(message.author.displayAvatarURL)
  .setDescription(message.author.username);

return message.reply(avatarEmbed);