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? :
/rbd/pnpm-volume/b94d2f9e-9e04-48f9-8932-522b88885c5b/node_modules/.registry.npmjs.org/tmi.js/1.2.1/node_modules/tmi.js/lib/commands.js:332
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/.registry.npmjs.org/tmi.js/1.2.1/node_modules/tmi.js/lib/commands.js:332:22)
at client.onConnectedHandler (/app/bot.js:62:10)
at client.EventEmitter.emit (/rbd/pnpm-volume/b94d2f9e-9e04-48f9-8932-522b88885c5b/node_modules/.registry.npmjs.org/tmi.js/1.2.1/node_modules/tmi.js/lib/events.js:96:25)
at client.EventEmitter.emits (/rbd/pnpm-volume/b94d2f9e-9e04-48f9-8932-522b88885c5b/node_modules/.registry.npmjs.org/tmi.js/1.2.1/node_modules/tmi.js/lib/events.js:64:19)
at client.handleMessage (/rbd/pnpm-volume/b94d2f9e-9e04-48f9-8932-522b88885c5b/node_modules/.registry.npmjs.org/tmi.js/1.2.1/node_modules/tmi.js/lib/client.js:144:26)
at parts.forEach (/rbd/pnpm-volume/b94d2f9e-9e04-48f9-8932-522b88885c5b/node_modules/.registry.npmjs.org/tmi.js/1.2.1/node_modules/tmi.js/lib/client.js:959:36)
at Array.forEach ()
at client._onMessage (/rbd/pnpm-volume/b94d2f9e-9e04-48f9-8932-522b88885c5b/node_modules/.registry.npmjs.org/tmi.js/1.2.1/node_modules/tmi.js/lib/client.js:958:11)
at WebSocket.onMessage (/rbd/pnpm-volume/b94d2f9e-9e04-48f9-8932-522b88885c5b/node_modules/.registry.npmjs.org/ws/1.0.1/node_modules/ws/lib/WebSocket.js:418:14)
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: [
    process.env.CHANNEL_NAME
  ]
};

// 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:
client.connect();

// 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! discord.gg/b3W2nNaVTEA 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! https://streamlabs.com/')
    } 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! instagram.com/t')
    } else if (commandName === 'hi') {
      client.say('Hi!')
    } else if(commandName === 'bye') {
      client.say('Cya')
    } else if(commandName === 'cya') {
      client.say("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

Probably

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

and

https://tmijs.com/

oh ok

i cant install any file on my computer