πŸŸͺconnect

Since you already defined your credentials with setCredentials method, is now time to establish a connection to an IRC server with the specified settings.

Syntax

bot.connect({
    server, 
    port, 
    ssl, 
    messageColor, 
    removeColors, 
    rejectUnauthorized,
    rejoinLimit,
    rejoinDelay,
    maxLineLength
});

Parameters

  • server (string, required) – The IRC server address to connect to.

  • port (number, required) – The port number to use for the connection.

  • ssl (boolean, required) – Determines whether to use SSL encryption.

  • messageColor (string, optional) – Sets the color for messages, based on the IRC Color Table.

  • removeColors (boolean, optional, default: true) – Removes IRC color codes from messages.

  • rejectUnauthorized (boolean, optional, default: false) – Whether to reject unauthorized SSL certificates.

  • rejoinLimit (number, optional) – Number of times it will try to rejoin a certain channel.

  • rejoinDelay (number, optional) – Delay (in ms) of wich it will try to rejoin a certain channel.

  • maxLineLength (number, optional) – Max. characters that is allowed per message, after that it will be splitted into the next message.

Example Usage

bot.connect({
    server: 'irc.libera.chat',
    port: 6697,
    ssl: true,
    messageColor: "green",
    removeColors: true,
    rejectUnauthorized: false,
    rejoinLimit: 3,
    rejoinDelay: 5000, // ms
    maxLineLength: 350
});

Notes

  • Ensure the server and port values match the intended IRC network.

  • If using SSL, make sure the server supports secure connections.

  • messageColor should correspond to a valid IRC color code.

  • Set rejectUnauthorized to true only if strict SSL verification is needed.

  • Once the connection is successfully established, the bot will emit a connected event.

Last updated