Creates a new LavalinkNode instance.
The Manager instance that controls this node
Configuration options for this Lavalink node as defined in LavalinkNodeOptions
ReadonlyhostThe hostname or IP address of the Lavalink server.
The identifier for this Lavalink node. Used to distinguish between multiple nodes.
The Manager instance that controls this node
ReadonlypasswordThe password used for authorization with the Lavalink server.
ReadonlyportThe port number that the Lavalink server is listening on.
The time in milliseconds between reconnection attempts if the connection fails.
The timeout in seconds after which a disconnected session can no longer be resumed.
Whether this node should attempt to resume the session when reconnecting.
ReadonlysecureWhether to use secure connections (HTTPS/WSS) instead of HTTP/WS.
OptionalsessionThe unique session identifier provided by Lavalink on successful connection.
OptionalstateCustom data that can be attached to the node instance.
The statistics received from the Lavalink server.
The version of the Lavalink protocol this node is using.
The WebSocket instance used for communication with the Lavalink server.
When not connected to Lavalink, this property will be null. You can check the connected property to determine connection status.
Indicates whether this node is currently connected to the Lavalink server.
true if connected, false otherwise
Checks if the ws instance exists and if its ready state is 1. This property is useful for verifying connection status before attempting operations or implementing node selection strategies.
Gets the REST API base URL for the Lavalink server.
The complete REST API base URL including protocol, host, port, and path
Returns either a secure (https://) or insecure (http://) REST URL based on the secure property configuration.
Gets the WebSocket URL for connecting to the Lavalink server.
The complete WebSocket URL including protocol, host, port, and path
Returns either a secure (wss://) or insecure (ws://) WebSocket URL based on the secure property configuration.
Establishes a connection to the Lavalink server.
This method creates a new WebSocket connection to the configured Lavalink server. If the node is already connected, it will close the existing connection first. The method sets up event listeners for the WebSocket to handle messages, errors, and connection state changes.
Note: This method is primarily used internally by the Manager class. Users typically should not call this method directly as the Manager handles node connections automatically.
A promise that resolves when connected or rejects if connection fails
Gracefully closes the connection to the Lavalink server.
This method closes the WebSocket connection with a normal closure code (1000) and a reason of "destroy", indicating an intentional disconnection rather than an error condition.
Note: This method is primarily used internally by the Manager class. Users typically should not call this method directly as the Manager handles node disconnections automatically.
void
The LavalinkNode class handles the connection and communication with a Lavalink server.
Remarks
LavalinkNode instances are typically created and managed by the Manager class, which handles load balancing across multiple nodes and routing player actions to the appropriate node.