kiwiirc / irc-framework

🛠️ A better IRC framework for node.js. For bots and full clients.
MIT License
181 stars 63 forks source link

TypeError on message event #289

Closed loljoho closed 2 years ago

loljoho commented 3 years ago

Using the example code from README.md:

bot.on('message', function(event) {
    if (event.message.indexOf('hello') === 0) {
          event.reply('Hi!');
    }

    if (event.message.match(/^!join /)) {
        var to_join = event.message.split(' ');
        event.reply('Joining ' + to_join + '..');
        bot.join(to_join);
    }
});

// Or a quicker to match messages...
bot.matchMessage(/^hi/, function(event) {
    event.reply('hello there!');
});

Responds as intended in IRC:

<Joho> hi
<ainu> hello there!
<Joho> !join hi
<ainu> Joining !join,hi..

However, in the console:

TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received an instance of Object
    at WriteStream.Writable.write (_stream_writable.js:285:13)
    at Duplex.ondata (_stream_readable.js:719:22)
    at Duplex.emit (events.js:315:20)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:284:9)
    at Duplex.Readable.push (_stream_readable.js:223:10)
    at Duplex.read [as _read] (/home/joho/code/ainu/node_modules/irc-framework/src/channel.js:169:32)
    at IrcClient.<anonymous> (/home/joho/code/ainu/node_modules/irc-framework/src/channel.js:182:28)
    at IrcClient.emit (/home/joho/code/ainu/node_modules/eventemitter3/index.js:181:35)
    at /home/joho/code/ainu/node_modules/irc-framework/src/client.js:223:24
TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received an instance of Object
    at WriteStream.Writable.write (_stream_writable.js:285:13)
    at Duplex.ondata (_stream_readable.js:719:22)
    at Duplex.emit (events.js:315:20)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:284:9)
    at Duplex.Readable.push (_stream_readable.js:223:10)
    at Duplex.read [as _read] (/home/joho/code/ainu/node_modules/irc-framework/src/channel.js:169:32)
    at IrcClient.<anonymous> (/home/joho/code/ainu/node_modules/irc-framework/src/channel.js:182:28)
    at IrcClient.emit (/home/joho/code/ainu/node_modules/eventemitter3/index.js:181:35)
    at /home/joho/code/ainu/node_modules/irc-framework/src/client.js:223:24

Node v14.15.0 on Snoonet, FYI.