Connects, but then error: No response from Twitch

First timer here. I’m following the guide at Getting Started | Twitch Developers

My code looks like this:

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

// Define configuration options
const opts = {
  identity: {
    username: 'CoonBot',
    password: 'oauth:xxxxxxxxxxxxxx'   // yes I am using the actual oath token
  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();
    client.say(target, `You rolled a ${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}`);

And then when I run it with Command Prompt…

Any ideas? :<

Someone on the TwitchDev Discord solved it for me.

The problem was that channel names should just be a username, not a URL. Also the username should have been my username, ‘gamershork’, instead of the bot’s registered name.

So instead of


it’s just


The username should match the account represented by the oauth token. So, if you want to send messages from a specific bot name, you will need an oauth token associated with the bot account.

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