I am using tmi.js, my client.say, is not working

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

// Define configuration options
const opts = {
  identity: {
    username: 'yugenfr',
    password: 'redacted'
  channels: [

// Create a client with our options
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 (target, context, msg, self) {
  //if (self) { return ; } // Ignore messages from the bot

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

  // If the command is known, let's execute it
  if (commandName === '!dice') {
    const num = rollDice();
    console.log(client.say(target, `You rolled ${num}`));
    client.say(target, `You rolled ${num}`);
    console.log(`* Executed ${commandName} command`);
  } else {
    console.log(`* Unknown command ${commandName}`);

// Function called when the "dice" command is issued
function rollDice () {
  const sides = 6;
  return Math.floor(Math.random() * sides) + 1;

// Called every time the bot connects to Twitch chat
function onConnectedHandler (addr, port) {
  console.log(`* Connected to ${addr}:${port}`);

This is my code, my code is seeing the message and my client.say() is sending the message, I consoled it. I am using the official twitch tutorial code and followed it step by step. I am using my streaming account as my bot account.

what’s not working?

I got it fixed, I was using my main account as the bot and it was not working after creating a secondary account I got it to work.

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