Error : Invalid Nick

When I Run my bot this error comes :
[05:26] error: Invalid NICK.
(node:2180) UnhandledPromiseRejectionWarning: Invalid NICK.
(node:2180) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:2180) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.strong text

That suggests the nick is invalid!

or the password/username combon is invalud

Whats the raw lines returned by the server when you connect?

that is literally it
no prob tho as it solved,
however i had some other error coming can you explain this one? :
if ((message.startsWith(".") && !message.startsWith("…")) || message.startsWith("/") || message.startsWith("\")) {

TypeError: Cannot read property ‘startsWith’ of undefined
at client.say (/rbd/pnpm-volume/b94d2f9e-9e04-48f9-8932-522b88885c5b/node_modules/
at client.onConnectedHandler (/app/bot.js:62:10)
at client.EventEmitter.emit (/rbd/pnpm-volume/b94d2f9e-9e04-48f9-8932-522b88885c5b/node_modules/
at client.EventEmitter.emits (/rbd/pnpm-volume/b94d2f9e-9e04-48f9-8932-522b88885c5b/node_modules/
at client.handleMessage (/rbd/pnpm-volume/b94d2f9e-9e04-48f9-8932-522b88885c5b/node_modules/
at parts.forEach (/rbd/pnpm-volume/b94d2f9e-9e04-48f9-8932-522b88885c5b/node_modules/
at Array.forEach ()
at client._onMessage (/rbd/pnpm-volume/b94d2f9e-9e04-48f9-8932-522b88885c5b/node_modules/
at WebSocket.onMessage (/rbd/pnpm-volume/b94d2f9e-9e04-48f9-8932-522b88885c5b/node_modules/
at emitTwo (events.js:126:13)

The variable message is undefined on line 332.

this is the code :

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

// Define configuration options
const opts = {
  identity: {
    username: process.env.BOT_USERNAME,
    password: process.env.OAUTH_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} 

    const commandName = msg.trim();

    if (commandName === '!discord') {
      client.say('Join my discord, and chat with me there! And if you would like to be notified for streams, just go on the roles channel and react to Twitch Pings! :D')
    } else if (commandName === '!donate') {
      client.say(' Here is the donation link for my twitch if ya wanna support me!')
    } else if (commandName === '!guild') {
      client.say('I have a hypixel guild! Feel free to join by typing /g join DartSyndicate in hypixel!')
    } else if (commandName === '!lurk') {
      client.say(` Thank you for lurking ${context.username}! Hope to see you around soon! `)
    } else if (commandName === '!editor') {
      client.say(' The best editor Dart could ever ask for, in return please do check her out on her instagram socials!')
    } else if (commandName === 'hi') {
    } else if(commandName === 'bye') {
    } else if(commandName === 'cya') {
    } else {
      console.log('Just a Message')

// Function called when the "dice" command is issued
function rollDice () {
  const sides = 20;
  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}`);
  console.log(`* Connected to ${addr}:${port}`);

  client.say('Bot Has Loaded! (Made By TheGreatArki) ')

The fault is in the library apparently. not in your code.

oh ok , but how do i make the bot work for my friends stream rn?

You make it join their channel.

The library you are using may have a helper for this

is their any other library?

im a new dev, so i dont really understand how to do join thing on the link u sent


I don’t tend to use a library for a chat bot other than ws for connection handling (which most Twitch specific libraries will use under the hood)

My one library/dependancy is ws for node

can you explain how to do the join thing in IRC Guide | Twitch Developers

Depends on if you are using a library or flat connection.

if a library refer to the documentation for that library on how to do it.

For regular ws/flat connectiong it’s just

what does flat connection mean?

i dont know the docs of tmi.js

means you are not using a “helper” library that wraps Twitch Chat functions into other functions.

Flat conenctiong: you speak IRC
Library: you speak library

Found via google


oh ok

i cant install any file on my computer

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