Skip to main content
Version: v2.9.1

Node

Table of Contentsโ€‹

Class Definitionโ€‹

export class Node {}

Propertiesโ€‹

Property Type Description
infoLavalinkInfoThe node info.
isNodeLinkbooleanWhether the node is a node link.
restRestThe rest instance.
sessionIdstringThe session ID.
socketWebSocketThe socket.
statsNodeStatsThe node stats.

Constructorโ€‹

new Node(manager: Manager, options: NodeOptions)
Parameter Type Description Optional
managerManagerThe manager instance.
optionsNodeOptionsThe node options.

Methodsโ€‹

address()โ€‹

address(): string

Returns the full address for this node, including the host and port.


connect()โ€‹

async connect(): Promise<void>

Connects to the node.


connected()โ€‹

connected(): boolean

Checks if the Node is currently connected.


createSessionIdsFile()โ€‹

createSessionIdsFile(): void

Creates a session ids file for this node.


deleteSponsorBlock()โ€‹

warning

โš ๏ธ This method only works when the node has the sponsor block plugin.

async deleteSponsorBlock(player: Player): Promise<void>

Deletes the sponsor block for this node.

Parametersโ€‹

Parameter Type Description Optional
playerPlayerThe player.

error()โ€‹

warning

โš ๏ธ This method is protected and should not be called directly.

error(error: Error): void

Handles an error.

Parametersโ€‹

Parameter Type Description Optional
errorErrorThe error.

fetchInfo()โ€‹

async fetchInfo(): Promise<LavalinkInfo>

Fetches the info for this node.

Returnsโ€‹

Type Description
Promise<LavalinkInfo>The node info.

getLyrics()โ€‹

warning

โš ๏ธ This method only works when the node has the LavaLyrics plugin.
Or the node is a NodeLink node.

async getLyrics(track: Track, skipTrackSource: boolean = false, language?: string): Promise<Lyrics | NodeLinkGetLyrics>

Gets the lyrics for a track.

Parametersโ€‹

Parameter Type Description Optional
trackTrackThe track.
skipTrackSourcebooleanWhether to skip the track source.
languagestringThe language.

Returnsโ€‹

Type Description
Promise<Lyrics | NodeLinkGetLyrics>The lyrics.

getSponsorBlock()โ€‹

warning

โš ๏ธ This method only works when the node has the sponsor block plugin.

async getSponsorBlock(player: Player): Promise<SponsorBlockSegment[]>

Gets the sponsor block for this node.

Parametersโ€‹

Parameter Type Description Optional
playerPlayerThe player.

Returnsโ€‹

Type Description
Promise<SponsorBlockSegment[]>The sponsor block.

handleEvent()โ€‹

warning

โš ๏ธ This method is protected and should not be called directly.

async handleEvent(payload: PlayerEvent & PlayerEvents): Promise<void>

Handles an event emitted from the Lavalink node.

Parametersโ€‹

Parameter Type Description Optional
payloadPlayerEvent | PlayerEventsThe payload.

loadSessionIds()โ€‹

async loadSessionIds(): Promise<void>

Loads the session ids for this node.


lyricsSubscribe()โ€‹

warning

โš ๏ธ This method only works when the node has the LavaLyrics plugin.

async lyricsSubscribe(guildId: string, skipTrackSource: boolean = false): Promise<unknown>

Subscribes to lyrics for a guild.

Parametersโ€‹

Parameter Type Description Optional
guildIdstringThe guild ID.
skipTrackSourcebooleanWhether to skip the track source.

Returnsโ€‹

Type Description
Promise<unknown>The promise that resolves to the response.

lyricsUnsubscribe()โ€‹

warning

โš ๏ธ This method only works when the node has the LavaLyrics plugin.

async lyricsUnsubscribe(guildId: string): Promise<unknown>

Unsubscribes from lyrics for a guild.

Parametersโ€‹

Parameter Type Description Optional
guildIdstringThe guild ID.

Returnsโ€‹

Return Description
Promise<unknown>The promise that resolves to the response.

message()โ€‹

warning

โš ๏ธ This method is protected and should not be called directly.

async message(d: Buffer | string): Promise<void>

Sends a message to the node.

Parametersโ€‹

Parameter Type Description Optional
dBuffer | stringThe data to send.

open()โ€‹

warning

โš ๏ธ This method is protected and should not be called directly.

open(): void

Opens the connection to the node.

queueEnd()โ€‹

async queueEnd(player: Player, track: Track, payload: TrackEndEvent): Promise<void>

Handles the event when a queue ends.

Parametersโ€‹

Parameter Type Description Optional
playerPlayerThe player.
trackTrackThe track.
payloadTrackEndEventThe payload.

setSponsorBlock()โ€‹

warning

โš ๏ธ This method only works when the node has the sponsor block plugin.

async setSponsorBlock(player: Player, segments: SponsorBlockSegment[] = [SponsorBlockSegment.Sponsor, SponsorBlockSegment.SelfPromo]): Promise<void>

Sets the sponsorblock segments for a player.

Parametersโ€‹

Parameter Type Description Optional
playerPlayerThe player.
segmentsSponsorBlockSegment[]The segments.

socketClosed()โ€‹

warning

โš ๏ธ This method is protected and should not be called directly.

socketClosed(player: Player, payload: WebSocketClosedEvent): void

Emitted when the WebSocket connection for a player closes.

Parametersโ€‹

Parameter Type Description Optional
playerPlayerThe player.
payloadWebSocketClosedEventThe payload.

trackEnd()โ€‹

async trackEnd(player: Player, track: Track, payload: TrackEndEvent): Promise<void>

Emitted when a track ends playing.

Parametersโ€‹

Parameter Type Description Optional
playerPlayerThe player.
trackTrackThe track.
payloadTrackEndEventThe payload.

trackError()โ€‹

warning

โš ๏ธ This method is protected and should not be called directly.

async trackError(player: Player, track: Track, payload: TrackExceptionEvent): Promise<void>

Handles the event when a track has an error during playback.

Parametersโ€‹

Parameter Type Description Optional
playerPlayerThe player.
trackTrackThe track.
payloadTrackExceptionEventThe payload.

trackStart()โ€‹

warning

โš ๏ธ This method is protected and should not be called directly.

trackStart(player: Player, track: Track, payload: TrackStartEvent): void

Emitted when a new track starts playing.

Parametersโ€‹

Parameter Type Description Optional
playerPlayerThe player.
trackTrackThe track.
payloadTrackStartEventThe payload.

trackStuck()โ€‹

warning

โš ๏ธ This method is protected and should not be called directly.

trackStuck(player: Player, track: Track, payload: TrackStuckEvent): void

Emitted when a track gets stuck.

Parametersโ€‹

Parameter Type Description Optional
playerPlayerThe player.
trackTrackThe track.
payloadTrackStuckEventThe payload.

updateSessionId()โ€‹

updateSessionId(): void

Updates the session ID.