如何检测消息中的嵌入?
How can I detect embeds in a message?
我试图让我的机器人阅读其他机器人的丰富嵌入,但我什至找不到从哪里开始这样做。我已经阅读了文档,但我仍然不知道该怎么做...
使用 if(message.content.includes(x))
不起作用,我该怎么办?
收到消息后,其嵌入存储在 <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
and MessageEmbedField
的文档中找到这些属性。
我试图让我的机器人阅读其他机器人的丰富嵌入,但我什至找不到从哪里开始这样做。我已经阅读了文档,但我仍然不知道该怎么做...
使用 if(message.content.includes(x))
不起作用,我该怎么办?
收到消息后,其嵌入存储在 <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
and MessageEmbedField
的文档中找到这些属性。