Twitch TMI Command Timeout

Hi All,

Im working on a Twitch Bot and currently when someone types a command it will reply back. But if someone spams the command it also spams it back. I want to set a cooldown so that when someone uses the Command “!play” it waits 1 min before looking to see if someone has sent it again.


client.connect();

  client.on('message', (channel, tags, message, self) => {

    if(self) return;

    if(message.toLowerCase() === '!play') {

      console.log(client.say(channel, `!play`));

    }

});

Basica javascript example that would suffice

var block = false;

client.connect();

  client.on('message', (channel, tags, message, self) => {

    if(self) return;

    if(message.toLowerCase() === '!play') {
      if (!block) {
          console.log(client.say(channel, `!play`));
          block = true;
          setTimeout(() => {
              block = false;
          }, (60 * 1000));
      }
    }

});
1 Like

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