Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/465.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何检测消息中的嵌入?_Javascript_Embed_Discord.js - Fatal编程技术网

Javascript 如何检测消息中的嵌入?

Javascript 如何检测消息中的嵌入?,javascript,embed,discord.js,Javascript,Embed,Discord.js,我试图让我的机器人读取其他机器人的丰富嵌入,但我甚至找不到从哪里开始。我已经看过文件了,但我仍然不知道该怎么办… 使用如果(message.content.includes(x))不起作用,我该怎么办?收到消息时,其嵌入存储在:为了读取它们,您可以循环该数组并查看每个嵌入的属性: client.on('message', message => { for (let embed of message.embeds) { // these are some of the propertie

我试图让我的机器人读取其他机器人的丰富嵌入,但我甚至找不到从哪里开始。我已经看过文件了,但我仍然不知道该怎么办…

使用
如果(message.content.includes(x))
不起作用,我该怎么办?

收到消息时,其嵌入存储在:为了读取它们,您可以循环该数组并查看每个嵌入的属性:

client.on('message', message => {
  for (let embed of message.embeds) { // these are some of the properties
    console.log(`
    Title: ${embed.title}
    Author: ${embed.author}
    Description: ${embed.description}
    `);
    for (let field of embed.field) {
      console.log(`
      Field title: ${field.name}
      Field value: ${field.value}
      `);
    }
  }
});

您可以在和的文档中找到这些属性。

收到消息时,其嵌入存储在:为了读取它们,您可以循环该数组并查看每个嵌入的属性:

client.on('message', message => {
  for (let embed of message.embeds) { // these are some of the properties
    console.log(`
    Title: ${embed.title}
    Author: ${embed.author}
    Description: ${embed.description}
    `);
    for (let field of embed.field) {
      console.log(`
      Field title: ${field.name}
      Field value: ${field.value}
      `);
    }
  }
});

您可以在和的文档中找到这些属性。

调试是您的朋友<代码>控制台。记录所有的事情,直到你找到你想要的。调试是你的朋友
console.log
所有的东西,直到你找到你想要的。谢谢!你的解释非常有效,我的机器人正在运行并发现恶意嵌入!很高兴听到:)谢谢!你的解释非常有效,我的机器人正在运行并发现恶意嵌入!很高兴听到:)