martynsmith / node-irc

NodeJS IRC client library
GNU General Public License v3.0
1.33k stars 424 forks source link

Type error I don't understand not caught with error listener #567

Closed MixtarMaster closed 2 years ago

MixtarMaster commented 2 years ago

Heyo!

So I'm developing a simple bot to quickly comunicate on a IRC server for a challenge. I only started to try and undetstand how it works before I actually do the challenge. So I just want to send a specific message to the challenge bot knowing what the answer will be but when i run my code i get this error:

D:\coding\javascript\candychatter\node_modules\irc\lib\irc.js:849
                        throw err;
                        ^

TypeError: self.opt.channels.forEach is not a function
    at Client.<anonymous> (D:\coding\javascript\candychatter\node_modules\irc\lib\irc.js:660:27)
    at Client.emit (events.js:315:20)
    at Client.<anonymous> (D:\coding\javascript\candychatter\node_modules\irc\lib\irc.js:368:22)
    at Client.emit (events.js:315:20)
    at iterator (D:\coding\javascript\candychatter\node_modules\irc\lib\irc.js:846:26)
    at Array.forEach (<anonymous>)
    at Socket.handleData (D:\coding\javascript\candychatter\node_modules\irc\lib\irc.js:841:15)
    at Socket.emit (events.js:315:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:280:11)

I have no idea what it's from because the error doesnt quote any of my code and it happens after getting the registered response and so far it's really bare bones:

const irc = require('irc');

const client = new irc.Client('irc.root-me.org', 'notHereForTheChallenge', {
    channels: '#root-me_challenge'
});

client.addListener('message', function (from, to, message) {
    console.log(from + ' => ' + to + ': ' + message);
});

client.addListener('error', function(message) {
    console.log('error: ', message);
});

client.addListener('registered', function (message) {
    console.log(message);
});

I was thinking it was because of an installation error but I reinstalled it twice with the error still poping.... help?

MixtarMaster commented 2 years ago

Was just a syntax error:

not:

const client = new irc.Client('irc.root-me.org', 'notHereForTheChallenge', {
    channels: '#root-me_challenge'
});

but:

const client = new irc.Client('irc.root-me.org', 'notHereForTheChallenge', {
    channels: ['#root-me_challenge']
});