Is my bot likely to be rate limited in a busy chatroom?

I have a chat bot and I need to know if / when it will be rate limited.

The chat bot listens to messages in 1 channel. It does not say anything, but collects answers to a quiz:

App.js

const tmi = require("tmi.js");

// Create a client with our options
const onMessageHandler = require("./modules/onMessageHandler.js");

// Connect to Twitch:
const client = new tmi.client(opts);
client.on("message", onMessageHandler);

onMessageHandler.js

module.exports = async function (target, context, msg, self) {
  // Ignore messages from the bot
  if (self) {
    return;
  }

  // Remove whitespace from chat message
  const commandName = msg.trim();

  // If it doesn't start with a !
  if (commandName.charAt(0) != "!") {
    return;
  }


  if (commandName.length < 2) {
    // console.log("not long enough...")
    return;
  }

  let vote = commandName.substring(1);

  if (isNaN(vote)) {
    // console.log("not a number", vote);
    return;
  }
  vote = parseInt(vote);
  let username = context.username;
  await setVote(username, vote);
};

The setVote function just stores the vote in the database.

Will this bot be subject to a rate limit, with every message counting towards its “points”:

or does TMI just call the API once when the bot first connects?

If you bot is operating in only one channel.
And that bot is a moderator in the channel.

Then in theory, it’ll be really difficult to hit the rate limit.

However:

Then your bot uses one point to JOIN
And that’s it.

If you bot sends no messages, then you use no rate limit points. And thus you can’t hit a rate limit, since you’ll just use the single point at connect.

You can even use an anonymous login to chat since you don’t intend to send any messages.

Just remember to PONG in response to Twitch’s PING to keep the connection alive (which tmi.js probably handles for you. Assuming when you say TMI you mean TMI.JS the JS library and not TMI which is the name of chat itself.

1 Like

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