Chat bot not sending messages

I’m using tmi.js in node on my desktop. im trying to write a simple chatbot that listens to channels for specific commands and replies. I’m following this tutorial: . For reference, I am testing this bot on my own channel (daalbhath) but the bot is itself a separate account (daalbot) and i generated an OAuth token for the bot account with

    const client = new tmi.client(opts);

    // Register our event handlers (defined below)
    client.on('message', onMessageHandler);
    client.on('connected', onConnectedHandler);

    // Connect to Twitch:

    // Called every time a message comes in
    function onMessageHandler (channel, tags, msg, self) {
      if (self) { return; } // Ignore messages from the bot

      // Remove whitespace from chat message
      const command: string = msg.trim();
      try {
        if (command.startsWith('!add-detractors')) {
            const detractors: string[] = command.split(' ').slice(1);
            if (detractors.length === 0) {
            client.say(channel, `Added ${detractors.join(', ')} to the list of detractors dspLeanin`);
          } else if (command.startsWith('!list-detractors')) {
            console.log('received command');
            client.say(channel, `There are currently ${currDetractors.length} known detractors`);
            client.say(channel, `The current detractors are: ${currDetractors.join(', ')}`);
          } else {
            console.log(`${channel}/${tags.username}: ${msg}`);
      } catch (err) {
          console.log(`something went wrong: ${err}`);
          console.log(`msg: ${msg}`);

The bot messages don’t show up in my channel. More specifically, only 1 message showed up and then all subsequent messages did not show up. No error is logged either. When I debugged, I did not see any abnormal behavior. The PRIVMSG call is being made. console.logs show that the onMessage handler is being called per message. Literally the message just does not show up in my channel (daalbhath). I also don’t have followers only or sub only or anything enabled.

I am now using a different twitch chat library and am still getting issues. This is with an authcode OAuth mechanism, and again while messages in the channel are being properly read, writing to the channel just is not working. I double-checked that the scope i chose when getting my authorization grant included chat:edit, so my bot should be able to write to the channel. but my bot is not able to write anything to my channel.

I have registered my application and passed the client id/client secret to my app manually. I have successfully fetched an auth token and refresh token. even with the new twitch chat client, the bots messages do not show up. Moreover, I logged into my bot’s account on an incognito browser, and tried manually sending messages to the channels i was listening to. Those messages did not show up. This seems to indicate to me some twitch issue/feature, probably where if 2 accounts are sending messages from the same IP, then one of the accounts is not able to send messages. When I log out of my primary account and then again try to send messages manually from my bot account, i am able to see the messages. However, the client is still not sending messages itself.

Found the issue: twitch doesn’t allow the same message to be sent multiple times within 30s. That’s why i was only seeing the bot sporadically. After enabling debug level logging on the bot thanks to the help of someone in the discord, I was able to see that the bot was working just fine.

Mods are exempt from this restriction

In other words run

/mod botName

On your channel but replace botName with your bot

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