1

I own a node twitch bot and I want to make it so a mod can do !timeout @(user) to set the timeout of the chatter for 600 seconds. How can this be done?

Here is some code I have so far:

client.on("message", (channel, user, message, self) => {
  if (self) return;

  if(message === "!timeout" && user.mod === true){
    client.say (channel, `/timeout @${user.id} 100000`);
  }
});
starball
  • 20,030
  • 7
  • 43
  • 238
christian
  • 11
  • 1

1 Answers1

1

What your code reads currently is when a moderator types !timeout ; it will timeout themself you need to set ARGS for the message to take in a username

client.on("message", (channel, user, message, self, tags) => {
  // Ignore echoed messages.
    if(self) return;
    //Check for MOD /broadcaster
    const badges = tags.badges || {};
    const isBroadcaster = badges.broadcaster;
    const isMod = badges.moderator;
    const isModUp = isBroadcaster || isMod;

  if(message.toLowerCase().startsWith("!timeout") && isModUp){
   var command = message.split(' ')
    client.say (channel, `/timeout ${command[1]} 100000`);
  }
});
swift gaming
  • 142
  • 4