本文介紹了如何檢測消息中的嵌入?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我正在嘗試讓我的機器人讀取其他機器人的豐富嵌入,但我什至找不到從哪里開始做.我已閱讀文檔,但我仍然不知道該怎么做...
使用 if(message.content.includes(x))
不起作用,我該怎么辦?
I'm trying to make my bot read other bots' rich embeds, but I can't even find where to start doing it. I've read the docs, but I still have no idea what to do...
Using if(message.content.includes(x))
doesn't work, what can I do?
推薦答案
收到消息后,其嵌入存儲在 <Message>.embeds
:為了讀取它們,您可以遍歷該數組并查看每個嵌入的屬性:
When a message is received, its embeds are stored in <Message>.embeds
: in order to read them, you can loop through that array and look at each embed's properties:
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
.
這篇關于如何檢測消息中的嵌入?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!