What I seek to do, is upon a message being sent, if that message is an embed, I want my bot to check the image in that embed (if there is one) for it's url, and if the url matches a specific url I provide, for the bot to send a specific message that I provide.
While I know the event for messages being sent ( client.on("message", function(message) {
) I have no idea how to have the bot check to see if that message is an embed, and how to have it check the url of the image in that embed, if there is one.
If you subscribe the event client.on("message")
, you'll recieve all the Messages the bot can read.
With message.embeds you'll get an array with all of the embeds on that message.
With MessageEmbed you can look at messageEmbed.thumbnail or messageEmbed.image depending on which one you want, and get the url out of it.
client.on("message", message => {
if(message.embeds.length > 0){
var embed = message.embeds[0];
if(embed.image && embed.image.url == "myurl.com"){
// do something
}
}
}
Something along those lines.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.