discord.js v13调用displayAvaterURL报client.user.display is not a function问询
问题原因与解决方案
核心错误:方法名拼写错误
你代码中调用的displayAvaterURL()拼写错误,Discord.js v13 提供的正确头像获取方法名为displayAvatarURL(),你将单词Avatar(头像)的第四个字母a误写为e,变成了不存在的方法名,才会触发client.user.display is not a function的运行时报错。
其他附带拼写错误
除了核心的方法名错误,你的代码里还有几处拼写错误会导致后续运行异常,需要一并修改:
setAuther应为setAuthorattachement://profile.png应为attachment://profile.png- 空字段值
\b200B应为\u200B
修改后的info命令关键代码片段
// 仅展示修改部分,其余逻辑保留即可 const userEmbed = new MessageEmbed() .setTitle(`${user.username}'s Information:'`) .setDescription("This is a description") .setURL("https://twitter.com/@emiluvik") .setAuthor("Emiluvik", client.user.displayAvatarURL(), "https://twitter.com/@emiluvik") .setThumbnail(client.user.displayAvatarURL()) .addFields( { name: `Username:`, value: `Username is: ${user.username}`, inline: true}, { name: `\u200B`, value: `\u200B`, inline: true}, { name: `Tag:`, value: `Tag is: #${user.discriminator}`, inline: true} ) .setImage("attachment://profile.png") .setTimestamp() .setColor("PURPLE") .setFooter(client.user.tag, client.user.displayAvatarURL())
修改完成后重新启动机器人即可正常运行该斜杠命令。
内容的提问来源于stack exchange,提问作者Emiluvik
相关产品推荐
相关产品推荐

