1

I made a feature in my discord bot to react to emojis with the same emoji, but when someone sends a message that isnt an emoji, it sends this error (it doesnt stop the bot, it just annoys me and floods the console)

Here it is:

client.on("message", message => {
  try {
    message.react(message.content);
  } catch (err) {
    console.log('')
  }
});

I tried looking for a way to check if the message is an emoji or not before running message.react(message.content);.

But i didn't find a result.

And here's the error: UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Emoji

m_hm0ud
  • 75
  • 1
  • 9
  • Does this answer your question? [How to detect emoji using javascript](https://stackoverflow.com/questions/18862256/how-to-detect-emoji-using-javascript) or this [https://stackoverflow.com/questions/30757193/find-out-if-character-in-string-is-emoji](https://stackoverflow.com/questions/30757193/find-out-if-character-in-string-is-emoji) – Mushroomator May 29 '22 at 12:35
  • I want to know how I can make the error not show up at all, so when I encounter another error that doesn't cause problems, I can fix it. And the other question is for swift, I want Node.js – m_hm0ud May 29 '22 at 12:37

1 Answers1

1

To ignore an error you can add .catch((err) => {}) to your code, for example:

message.react("").catch((err) => {})
MegaMix_Craft
  • 2,199
  • 3
  • 10
  • 36