Check if it is the user's first message in the transmission


First of all sorry for my English is not my native language.

I’m creating a bot, with tmi.js where one of its features will be to send a welcome message in the chat, but it has to be only in the first message that the user types, in the transmission. My question is this how to make this verification that it is the user’s first message and not stay, sending several messages every time something is typed?

Thank you very much for your attention.


Incomplete javascript example

var has_spoken = [];

on('message', (stuff) => {

if (has_spoken.indexOf(userID) >= 0) {
    // not first message
} else {
    // is first message


Your question is a basic programming question.

Not really a TwitchAPI or TMI question.

You just need a way to store/collect the data then see if they have spoken already or not.


get it, thank you very much!