Class : Node
Constructorโ
- Node : options
new Magmastream.Node(options: NodeOptions)
| Parameter | Type | Description | Optional |
|---|---|---|---|
host | string | The host for the node. | |
port | number | The port for the node. | |
password | string | The password for the node. | |
secure | boolean | Whether the host uses SSL. | |
identifier | string | The identifier for the node. | |
retryAmount | number | The retryAmount for the node. | |
retryDelay | number | The retryDelay for the node. | |
resumeStatus | boolean | Whether to resume the previous session. | |
resumeTimeout | number | The time the lavalink server will wait before it removes the player. | |
requestTimeout | number | The timeout used for api calls. | |
priority | number | Priority of the node. |
Table of contentsโ
Propertiesโ
socketโ
The socket for the node.
statsโ
The stats for the node.
Return:
nodeStats{}
managerโ
The manager for the node.
Return:
Manager
sessionIdโ
The node's session ID.
restโ
readonlyThe REST instance.
Return:
Rest
infoโ
Actual Lavalink information of the node.
Return:
lavalinkInfo{}| null
Methodsโ
address()โ
getReturns the address for this node.
Return: string
connected()โ
getReturns if connected to the Node.
Return: boolean
connect()โ
Connects to the Node.
If the node is already connected, this method will do nothing.
If the node has a session ID, it will be sent in the headers of the WebSocket connection.
If the node has no session ID but theresumeStatusoption is true, it will use the session ID
stored in the sessionIds.json file if it exists.Return: void
createSessionIdsFile()โ
Creates the sessionIds.json file if it doesn't exist. This file is used to store the session IDs for each node. The session IDs are used to identify the node when resuming a session.
Return: void
deleteSponsorBlock(player)โ
Deletes the sponsorblock segments for a player.
Parameter Type Description Optional playerPlayerThe player to delete the sponsorblocks for.
destroy()โ
async functionDestroys the node and cleans up associated resources.
This method emits a debug event indicating that the node is being destroyed and attempts to automatically move all players connected to the node to a usable one. It then closes the WebSocket connection, removes all event listeners, and clears the reconnect timeout. Finally, it emits a "nodeDestroy" event and removes the node from the manager.
fetchInfo()โ
async functionFetches Lavalink node information.
Return: Promise<
lavalinkInfo{}>
getLyrics(track, skipTrackSource)โ
async functionFetches the lyrics of a track from the Lavalink node.
This method uses thelavalyrics-pluginto fetch the lyrics. If the plugin is not available, it will throw a RangeError.Return: Promise<
lyrics{}>
Parameter Type Description Optional tracktrack{}The track to fetch the lyrics for. skipTrackSourceboolean Whether to skip using the track's source URL.
getSponsorBlock(player)โ
async functionGets the current sponsorblock segments for a player.
Return: Promise<
sponsorBlockSegment[]>
Parameter Type Description Optional playerPlayerThe player to get the sponsor blocks for.
loadSessionIds()โ
Loads session IDs from the sessionIds.json file if it exists. The session IDs are used to resume sessions for each node.
The session IDs are stored in the sessionIds.json file as a composite key of the node identifier and cluster ID. This allows multiple clusters to be used with the same node identifier.Return: void
setSponsorBlock(player, segments)โ
async functionUpdates the session ID in the sessionIds.json file.
This method is called after the session ID has been updated, and it writes the new session ID to the sessionIds.json file.
Parameter Type Description Optional playerPlayerThe player to set the sponsor blocks for. segmentsSponsorBlockSegment[] The sponsorblock segments to set. Defaults to ["sponsor", "selfpromo"]if not provided.
updateSessionId()โ
Updates the session ID in the sessionIds.json file.
This method is called after the session ID has been updated, and it writes the new session ID to the sessionIds.json file.Return: void