简体   繁体   English

Discord.JS RichEmbed建筑

[英]Discord.JS RichEmbed Building

fellow Developers! 各位开发人员! I've been having a ton of issue over the past couple hours with Discord.JS's embedding technique. 在过去的几个小时中,Discord.JS的嵌入技术给我带来了很多问题。 I keep getting: 我不断得到:

TypeError: Cannot read property 'client' of undefined at new MessageEmbed (folder\\node_modules\\discord.js\\src\\structures\\MessageEmbed.js:13:60) at embed (folder\\rlxob.js:17:13) at Client.client.on.message(folder\\rlxob.js:193:15) TypeError:无法在客户端嵌入(folder \\ rlxob.js:17:13)的新MessageEmbed(文件夹\\ node_modules \\ discord.js \\ src \\ structures \\ MessageEmbed.js:13:60)读取未定义的属性“客户端”。 client.on.message(文件夹\\ rlxob.js:193:15)

And from what I understand, the rest beyond that doesn't matter, but here's a Gyazo image if you want to see the entire output. 从我的理解来看,其余的都没关系,但是如果您想查看整个输出,可以使用Gyazo图像 MessageEmbed.js line 13 says Object.defineProperty(this, 'client', { value: message.client }); MessageEmbed.js第13行表示Object.defineProperty(this, 'client', { value: message.client }); which is leaving me a bit confused. 这让我有些困惑。 It seems to expect the message variable to already be defined in class MessageEmbed {constructor (message, data) { but my code matches up with every single tutorial on message embedding that I have checked, double-checked, and gonna find out who's naughty or nice. 似乎期望message变量已经在class MessageEmbed {constructor (message, data) {定义了class MessageEmbed {constructor (message, data) {但是我的代码与我检查,仔细检查并要找出谁的顽皮或很好 And this piece of... well, I have no nice words to say, so I won't say any of them. 这...好吧,我没有话要说,所以我什么也不会说。 To leave you with a few bits of information that might help, node is running on version 8.9.4 and Discord.JS is running on version 11.2.1 . 为了给您提供一些可能有用的信息, node8.9.4版上运行, Discord.JS11.2.1版上运行。 This is really getting on my nerves, there isn't a clear answer that I can figure out. 这真的让我感到不安,我没有一个明确的答案。 Thanks for the help, guys! 谢谢大家的帮助! If you need any new information, I'll be checking back here. 如果您需要任何新信息,我将在这里再次检查。 If I don't reply, probably means I figured it out, however unlikely that may be. 如果我不回答,则可能意味着我已经弄清楚了,但是可能不太可能。

I understand you have double checked but just to make sure this is my embed that works fine: 我了解您已仔细检查过,但只是为了确保这是我的嵌入作品,可以正常工作:

case "info":
  var embed = new Discord.RichEmbed()
    .addField("General-Commands", "::games, ::people")
    .addField("Other-Commands", "::example, ::gamble")
    .addField(
      "Music-Commands",
      "::play <playlisturl>/search, ::skip, ::pause/resume, ::stop, ::queue"
    );
  message.channel.sendEmbed(embed);
  break;

You probably didn't define Client , so this is what you'll have to add: 您可能没有定义Client ,所以这是您必须添加的内容:

const client = new Discord.Client({disableEveryone: true})

Note: {disableEveryone} is optional. 注意: {disableEveryone}是可选的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM