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?