Bot Read Embed Messages

So ive been trying to find out a solution for this, i want the bot to read embed messages and react on them. I tried to get help from several coders and i got different codes and all of them are good and have no errors but when i run on discord it doesnt work.

last one i got :
client.on(“message”, async message => {
const { embeds } = message
if(!embeds || !embeds[0]) return

if(embeds[0].title && embeds[0].title == "✈Airdrop Apears") {
  if(message.author.id != "294882584201003009" || message.author.id != "617037497574359050" || message.author.id != "582537632991543307") return
  message.react("🎉")
} 

})

1 Like
client.on(“message”, async message => {
    const { embeds } = message
    if (!embeds || !embeds[0]) return

    if (embeds[0].title && embeds[0].title == "✈Airdrop Apears") {
        if (message.author.id != "294882584201003009" || message.author.id != "617037497574359050" || message.author.id != "582537632991543307") return
        message.react("🎉")
    }
})

I’m not very familiar with Discord.js, but I see a few problems in your code.

  1. You’re using the short-circuiting OR operand on line 3, but you don’t need it. if (!embeds) would work the same. Perhaps you’ve had errors with the embed or embed[0] (whatever that is) not existing? If that’s the case, check how you’re getting information - embeds should have the same format every time.
  2. On line 4, you don’t need the && - that might be slowing down your code. Just check if embeds[0].title has the right value - try adding an else block for error handling.
  3. Finally, it seems like you have an async function but don’t do anything asynchronous inside. Is this required by the docs? I’m not sure.

Hope this helps!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.