【发布时间】:2019-05-15 06:11:40
【问题描述】:
我试图让我的机器人读取其他机器人的丰富嵌入,但我什至找不到从哪里开始做。我已阅读文档,但我仍然不知道该怎么做...
使用if(message.content.includes(x)) 不起作用,我该怎么办?
【问题讨论】:
-
调试是你的朋友。
console.log所有的东西,直到你找到你要找的东西。
标签: javascript embed discord.js
我试图让我的机器人读取其他机器人的丰富嵌入,但我什至找不到从哪里开始做。我已阅读文档,但我仍然不知道该怎么做...
使用if(message.content.includes(x)) 不起作用,我该怎么办?
【问题讨论】:
console.log 所有的东西,直到你找到你要找的东西。
标签: javascript embed discord.js
收到消息后,其嵌入存储在<Message>.embeds:为了读取它们,您可以遍历该数组并查看每个嵌入的属性:
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}
`);
}
}
});
您可以在 MessageEmbed 和 MessageEmbedField 的文档中找到这些属性。
【讨论】: