martynsmith / node-irc

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

Client.say/notice ect #509

Closed Gaz492 closed 1 year ago

Gaz492 commented 7 years ago

I dont know if im doing something wrong but if i export client and try to use client.say(channel, message) in another file with client required i get client.say is not a function

john-patterson commented 7 years ago

Cannot recreate without more detail.

Here is my client.js file:

let irc = require('irc');

let defaultConfig = {
  server: 'us.undernet.org',
  nick: 'exportClientTest',
  chan: '#exportClientTest'
};

let ircClient = new irc.Client(defaultConfig.server, defaultConfig.nick, {
  channels: [defaultConfig.chan],
});

ircClient.addListener('error', (msg) => {
  console.error('[ERR] ' + msg);
});

module.exports = {
  client: ircClient,
  channel: defaultConfig.chan
};

and here is the file that uses it:


let {client, channel} = require('./client');

setInterval(() => {
  client.say(channel, 'Hello, World!');
}, 10000);

Here is the result: irc channel showing Hello World post