Client.say doesn't send a message

Hello everyone, so I’m working on a simple chatbot, everything was working fine until I tried to check if a message is from a mod or not, after thinking I may have messed up my code, I just crtl+z my way back to a “stable” version (the one posted here) but doing so, the bot doesn’t reply to commands in the chat. I can’t find what I did wrong. I would also appreciate knowing how can I check that the message (or the command) is from a mod. Thanks!

client.on("message", onMessageHandler);
// Connect to Twitch:
client.connect();
function onMessageHandler (target, context, msg, self) {
// Called every time a message comes in
if (self) { return; } // Ignore messages from the bot


  // Remove whitespace from chat message
  const commandName = msg.trim();
  if(commandName==="!rq"){
     const fs = require("fs");
     var quotes = fs.readFileSync('quotes.txt').toString().split("\n");
    var index =Math.floor(Math.random() * quotes.length);
      client.say(
        target,
        ` ${quotes[index]}`
      );
    }
   

   else if(commandName.includes("!addquote")){
      const fs = require("fs");
      const words = commandName.split(' ');
      var quote_to_add = words[1];
      var i;
      for(i=2;i<words.length;i++){
        quote_to_add = quote_to_add +" " + words[i];
      }
      fs.readFile('quotes.txt', function (err, data) {
  if (err) throw err;
  if(data.includes(quote_to_add)){
    console.log(data);
     client.say(
          target,
          `Quote already present!`
        );}
        else{
   fs.appendFile('quotes.txt',`\n ${quote_to_add}`, function (err) {
        if (err) return console.log(err);
        client.say(
          target,
          `Added quote ${quote_to_add}`
        );
      });
  }
});
      }
    }

EDIT: added console logs to the code, looks like i figured out how to recognize mod messages

if(commandName.includes("!addquote")&&user.mod)
yet, client.say(target, 'Added quote ${quote_to_add}'); doesn’t send the message in the chat.

The .mod is deprecated and isn’t accurate. Use the badges to see if they have the moderator badge instead.

Thank you for the reply!
The reason why client.say wasn’t actually sending the message to chat was the fact that i accidentally set a time out for longer than i wanted to (for anyone looking for a solution)

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