【问题标题】:"Rich is not defined" when trying to build an embed尝试构建嵌入时“未定义丰富”
【发布时间】:2019-04-22 03:31:12
【问题描述】:

我编写了这样的代码来为我的 Discord 机器人构建嵌入,但它似乎不起作用:

client.on('message', message => {
  // Ignore messages that aren't from a guild
  if (!message.guild) return;

  if (message.content.startsWith('$Commands')) {
    let Embed = new Rich.Embed;
    let Message = message.guild;
    let botEmbed = new Discord.RichEmbed()
      .setTitle("Commands From TTB")
      .setDescription("**Commands :**")
      .setColor("#4dff077")
      .setAuthorName("Galak$y#3038")
      .setAvatar("https://cdn.discordapp.com/avatars/563449221701959700/8386d5fe48d71898c40244e7a5a66d58.png")
      .addField("1. *Ban* = *Bans User Mentioned After Command* ``$ban <Mention User>``")
      .addField("2. Kick = Kicks User Mentioned After Command ``$kick <Mention User>``")
      .addField("3. what is myavatar = ``$what is my avatar``")
      .addFooter("New Commands Coming Soon...")
    return;
    message.channel.send(botEmbed)
  }
});

这是错误:

【问题讨论】:

  • 我不想让别人问我为什么放错误的照片或任何东西,只要给我一个问题的答案,或者一个新代码
  • 嗨,欢迎来到 Stack Overflow!我们不要求您无缘无故地将您的代码和错误作为文本而不是图像:这些方式更好,因为对于阅读有问题的人来说更容易,或者只是对于需要复制粘贴您的代码/错误的用户。最后,将代码编写为文本可以让人们更快地回答,因为他们在转录图像上花费的时间更少:请记住,没有人付钱给我们,您至少应该帮助我们解决您的问题。欲了解更多信息,请阅读:idownvotedbecau.se/imageofcode。祝你有美好的一天:)

标签: javascript node.js discord.js


【解决方案1】:

嵌入是使用RichEmbed 类构造函数创建的,如下所示:

let embed = new Discord.RichEmbed()

当您声明Embed 时,您使用的是Rich.Embed,正如它所说,Rich 是未定义的。

【讨论】:

    猜你喜欢
    • 2019-07-31
    • 2020-08-12
    • 2021-08-16
    • 2021-07-17
    • 2019-11-01
    • 2021-06-28
    • 2021-11-26
    • 1970-01-01
    • 2019-09-05
    相关资源
    最近更新 更多