You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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 应为 setAuthor
  • attachement://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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.01 14:18:00