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 theresumeStatus
option 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 player
Player
The 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-plugin
to fetch the lyrics. If the plugin is not available, it will throw a RangeError.Return: Promise<
lyrics{}
>
Parameter Type Description Optional track
track{}
The track to fetch the lyrics for. skipTrackSource
boolean 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 player
Player
The 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 player
Player
The player to set the sponsor blocks for. segments
SponsorBlockSegment[] 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