我尝试做嵌入头像的欢迎信息 它对我的 TypeError 说:guildMember.displayAvatarURL is not a function
client.on('guildMemberAdd' , guildMember =>{
let welcomeRole = guildMember.guild.roles.cache.find(r => r.id === "778565734217416711")
const embed = new Discord.MessageEmbed()
guildMember.roles.add(welcomeRole);
guildMember.guild.channels.cache.get('802194812521939006').send(embed)
embed.setTitle(`<@${guildMember.user.id}> ברוך הבא`)
embed.setDescription(`<@${guildMember.user.id}> ברוך הבא לשרת המטורף הזה`)
embed.setThumbnail(guildMember.displayAvatarURL())
});
答案 0 :(得分:1)
您不能显示 GuildMember 对象的头像,但首先必须将其转换为 User 对象。
client.on('guildMemberAdd' , guildMember =>{
let welcomeRole = guildMember.guild.roles.cache.find(r => r.id === "778565734217416711")
const embed = new Discord.MessageEmbed()
guildMember.roles.add(welcomeRole);
guildMember.guild.channels.cache.get('802194812521939006').send(embed)
embed.setTitle(`<@${guildMember.user.id}> ברוך הבא`)
embed.setDescription(`<@${guildMember.user.id}> ברוך הבא לשרת המטורף הזה`)
embed.setThumbnail(guildMember.user.displayAvatarURL())
});