Node
Table of Contentsโ
Class Definitionโ
export class Node {}
Propertiesโ
Property Type Description infoLavalinkInfoThe node info. isNodeLinkboolean Whether the node is a node link. restRestThe rest instance. sessionIdstring The session ID. socketWebSocket The socket. statsNodeStatsThe node stats.
Constructorโ
new Node(manager: Manager, options: NodeOptions)
Parameter Type Description Optional managerManagerThe manager instance. optionsNodeOptionsThe node options.
Methodsโ
address()โ
address(): stringReturns the full address for this node, including the host and port.
connect()โ
async connect(): Promise<void>Connects to the node.
connected()โ
connected(): booleanChecks if the Node is currently connected.
createSessionIdsFile()โ
createSessionIdsFile(): voidCreates a session ids file for this node.
deleteSponsorBlock()โ
โ ๏ธ 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()โ
โ ๏ธ This method is protected and should not be called directly.
error(error: Error): voidHandles an error.
Parametersโ
Parameter Type Description Optional errorError The error.
fetchInfo()โ
async fetchInfo(): Promise<LavalinkInfo>Fetches the info for this node.
Returnsโ
Type Description Promise< LavalinkInfo>The node info.
getLyrics()โ
โ ๏ธ 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. skipTrackSourceboolean Whether to skip the track source. languagestring The language. Returnsโ
Type Description Promise< Lyrics|NodeLinkGetLyrics>The lyrics.
getSponsorBlock()โ
โ ๏ธ 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()โ
โ ๏ธ 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()โ
โ ๏ธ 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 guildIdstring The guild ID. skipTrackSourceboolean Whether to skip the track source. Returnsโ
Type Description Promise<unknown> The promise that resolves to the response.
lyricsUnsubscribe()โ
โ ๏ธ 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 guildIdstring The guild ID. Returnsโ
Return Description Promise<unknown> The promise that resolves to the response.
message()โ
โ ๏ธ 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 | string The data to send.
open()โ
โ ๏ธ This method is protected and should not be called directly.
open(): voidOpens 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()โ
โ ๏ธ 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()โ
โ ๏ธ This method is protected and should not be called directly.
socketClosed(player: Player, payload: WebSocketClosedEvent): voidEmitted 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()โ
โ ๏ธ 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()โ
โ ๏ธ This method is protected and should not be called directly.
trackStart(player: Player, track: Track, payload: TrackStartEvent): voidEmitted when a new track starts playing.
Parametersโ
Parameter Type Description Optional playerPlayerThe player. trackTrackThe track. payloadTrackStartEventThe payload.
trackStuck()โ
โ ๏ธ This method is protected and should not be called directly.
trackStuck(player: Player, track: Track, payload: TrackStuckEvent): voidEmitted when a track gets stuck.
Parametersโ
Parameter Type Description Optional playerPlayerThe player. trackTrackThe track. payloadTrackStuckEventThe payload.
updateSessionId()โ
updateSessionId(): voidUpdates the session ID.