我不知道该怎么做,以致于当我使用此代码时,它不仅会给我我的头像,而且还会给我提到其他用户。我需要使用Richembeds进行此操作,如下所示。帮助,请。
} else if (command === 'avatar') {
const embed = new Discord.RichEmbed()
.setAuthor('Akirabot. Your avatar.')
.setColor(0x348fcd)
.setTitle('')
.addField(`${message.author.avatarURL}`, `Your avatar, click to url to open image with size 2048px.`, true)
.setFooter('— Akirabot.')
.setTimestamp()
.setImage(`${message.author.avatarURL}`, true)
message.channel.send({ embed });
答案 0 :(得分:0)
let user = message.mentions.users.first() || message.author;
,如果您提到某人,它将得到提及;如果没有提及,它将成为消息作者。
} else if (command === 'avatar') {
let user = message.mentions.users.first() || message.author;
const embed = new Discord.RichEmbed()
.setAuthor('Akirabot. Your avatar.')
.setColor(0x348fcd)
.setTitle('')
.addField(`${user.avatarURL}`, `Your avatar, click to url to open image with size 2048px.`, true)
.setFooter('— Akirabot.')
.setTimestamp()
.setImage(`${user.avatarURL}`, true)
message.channel.send({ embed });
答案 1 :(得分:0)
因为我回复的时候是 Discord js v12 rn,你可以使用 ClientUser#displayAvatarURL 作为你的机器人 例如:message.author.displayAvatarURL()