πͺ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
totrue
only if strict SSL verification is needed.Once the connection is successfully established, the bot will emit a
connected
event.
Last updated