Scarlet D.
Scarlet D.

Reputation: 173

Discord bot reacts just sometimes

I recently been struggling with a small and easy to make script on my discord bot. The script is supposed to make the bot react to whatever image (and only image) is posted to a certain channel. Thing is the bot reacts just SOMETIMES and it really seems random when it reacts, the script never really functioned as intended but at some point it did work on every picture of the channel, after a restart I did deliberately it again functioned randomly.

client.on("message", message => {
if (message.author.bot) return;
let prefix = ';';

if (message.channel.id == showoffid){
  const collector = new Discord.MessageCollector(
    message.channel,
    m => m.author.id === message.author.id,
    {}
  );
  collector.on('collect', message => {
    if (message.attachments.size > 0) {
     message.react('✨')
      .catch(console.error);
      return;
    }
  })
}

if (message.channel.id == hundoid){
  const collector = new Discord.MessageCollector(
    message.channel,
    m => m.author.id === message.author.id,
    {}
  );
  collector.on('collect', message => {
    if (message.attachments.size > 0) {
     message.react('💯')
      .catch(console.error);
      return;
    }
  })
}
}

Upvotes: 0

Views: 92

Answers (1)

Cipher
Cipher

Reputation: 2722

You can use this code and then its stop work random.

client.on("message", message => {
    if (message.author.bot) return;
    let prefix = ';';

    if (message.channel.id == showoffid){
            if (message.attachments.size > 0) {
             message.react('✨')
                .catch(console.error);
                return;
            }
    }

    if (message.channel.id == hundoid){
            if (message.attachments.size > 0) {
             message.react('💯')
                .catch(console.error);
                return;
            }
    }
}

Upvotes: 1

Related Questions