Home > Net >  Discord.JS (14.0) Random chance to React with Emoji?
Discord.JS (14.0) Random chance to React with Emoji?

Time:10-15

I'm very new to JS, and DiscordJS in general.

I am trying to get my bot to have a CHANCE to react to any message from a specific user, with a specific emoji ID.

The documentation I found says to use "client.emojis.find", but I get a TypeError that tells me this is not a function.

Any help is appreciated!

client.on("messageCreate", (message) => {
  if (message.author.id === "217900978756780032") {
    const otterEmoji = client.emojis.find(
      (emoji) => emoji.id === "1028007226859855914"
    );
    if (Math.random() < 0.5) {
      message.react("otterEmoji");
    }
  }
});

EDIT: This seems to work, but if anyone has other ideas for a cleaner randomizer, let me know!

client.on("messageCreate", (message) => {
  const a = Math.floor(Math.random() * 11);
  if (a >= 8) {
    if (message.author.id === "217900978756780032") {
      message.react("           
  • Related