LavalinkNode
Lavalink Node creator class
Constructors
new LavalinkNode()
Create a new Node
Parameters
Parameter | Type | Description |
---|---|---|
options | LavalinkNodeOptions | Lavalink Node Options |
manager | NodeManager | Node Manager |
Returns
Example
Defined in
Properties
Property | Modifier | Type | Default value | Description | Defined in |
---|---|---|---|---|---|
calls | public | number | 0 | The amount of rest calls the node has made. | src/structures/Node.ts:31 |
decode | public | object | undefined | Decode Track or Tracks | src/structures/Node.ts:629 |
decode.multipleTracks | public | (encodeds : string [], requester : unknown ) => Promise <Track []> | undefined | Decodes multiple tracks into their info Example const encodedBase64_1 = 'QAACDgMACk5vIERpZ2dpdHkAC0JsYWNrc3RyZWV0AAAAAAAEo4AABjkxNjQ5NgABAB9odHRwczovL2RlZXplci5jb20vdHJhY2svOTE2NDk2AQBpaHR0cHM6Ly9lLWNkbnMtaW1hZ2VzLmR6Y2RuLm5ldC9pbWFnZXMvY292ZXIvZGFlN2EyNjViNzlmYjcxMjc4Y2RlMjUwNDg0OWQ2ZjcvMTAwMHgxMDAwLTAwMDAwMC04MC0wLTAuanBnAQAMVVNJUjE5NjAwOTc4AAZkZWV6ZXIBAChObyBEaWdnaXR5OiBUaGUgVmVyeSBCZXN0IE9mIEJsYWNrc3RyZWV0AQAjaHR0cHM6Ly93d3cuZGVlemVyLmNvbS9hbGJ1bS8xMDMyNTQBACJodHRwczovL3d3dy5kZWV6ZXIuY29tL2FydGlzdC8xODYxAQBqaHR0cHM6Ly9lLWNkbnMtaW1hZ2VzLmR6Y2RuLm5ldC9pbWFnZXMvYXJ0aXN0L2YxNmNhYzM2ZmVjMzkxZjczN2I3ZDQ4MmY1YWM3M2UzLzEwMDB4MTAwMC0wMDAwMDAtODAtMC0wLmpwZwEAT2h0dHBzOi8vY2RuLXByZXZpZXctYS5kemNkbi5uZXQvc3RyZWFtL2MtYTE1Yjg1NzFhYTYyMDBjMDQ0YmY1OWM3NmVkOTEyN2MtNi5tcDMAAAAAAAAAAAA='; const encodedBase64_2 = 'QAABJAMAClRhbGsgYSBMb3QACjQwNHZpbmNlbnQAAAAAAAHr1gBxTzpodHRwczovL2FwaS12Mi5zb3VuZGNsb3VkLmNvbS9tZWRpYS9zb3VuZGNsb3VkOnRyYWNrczo4NTE0MjEwNzYvMzUyYTRiOTAtNzYxOS00M2E5LWJiOGItMjIxMzE0YzFjNjNhL3N0cmVhbS9obHMAAQAsaHR0cHM6Ly9zb3VuZGNsb3VkLmNvbS80MDR2aW5jZW50L3RhbGstYS1sb3QBADpodHRwczovL2kxLnNuZGNkbi5jb20vYXJ0d29ya3MtRTN1ek5Gc0Y4QzBXLTAtb3JpZ2luYWwuanBnAQAMUVpITkExOTg1Nzg0AApzb3VuZGNsb3VkAAAAAAAAAAA='; const tracks = await player.node.decode.multipleTracks([encodedBase64_1, encodedBase64_2], interaction.user); | src/structures/Node.ts:661 |
decode.singleTrack | public | (encoded : string , requester : unknown ) => Promise <Track > | undefined | Decode a single track into its info Example const encodedBase64 = 'QAACDgMACk5vIERpZ2dpdHkAC0JsYWNrc3RyZWV0AAAAAAAEo4AABjkxNjQ5NgABAB9odHRwczovL2RlZXplci5jb20vdHJhY2svOTE2NDk2AQBpaHR0cHM6Ly9lLWNkbnMtaW1hZ2VzLmR6Y2RuLm5ldC9pbWFnZXMvY292ZXIvZGFlN2EyNjViNzlmYjcxMjc4Y2RlMjUwNDg0OWQ2ZjcvMTAwMHgxMDAwLTAwMDAwMC04MC0wLTAuanBnAQAMVVNJUjE5NjAwOTc4AAZkZWV6ZXIBAChObyBEaWdnaXR5OiBUaGUgVmVyeSBCZXN0IE9mIEJsYWNrc3RyZWV0AQAjaHR0cHM6Ly93d3cuZGVlemVyLmNvbS9hbGJ1bS8xMDMyNTQBACJodHRwczovL3d3dy5kZWV6ZXIuY29tL2FydGlzdC8xODYxAQBqaHR0cHM6Ly9lLWNkbnMtaW1hZ2VzLmR6Y2RuLm5ldC9pbWFnZXMvYXJ0aXN0L2YxNmNhYzM2ZmVjMzkxZjczN2I3ZDQ4MmY1YWM3M2UzLzEwMDB4MTAwMC0wMDAwMDAtODAtMC0wLmpwZwEAT2h0dHBzOi8vY2RuLXByZXZpZXctYS5kemNkbi5uZXQvc3RyZWFtL2MtYTE1Yjg1NzFhYTYyMDBjMDQ0YmY1OWM3NmVkOTEyN2MtNi5tcDMAAAAAAAAAAAA='; const track = await player.node.decode.singleTrack(encodedBase64, interaction.user); | src/structures/Node.ts:642 |
info | public | LavalinkInfo | null | Actual Lavalink Information of the Node | src/structures/Node.ts:59 |
isAlive | public | boolean | false | - | src/structures/Node.ts:27 |
lyrics | public | object | undefined | - | src/structures/Node.ts:673 |
lyrics.get | public | (track : Track , skipTrackSource : boolean ) => Promise <LyricsResult > | undefined | Get the lyrics of a track Example const lyrics = await player.node.lyrics.get(track, true); // use it of player instead: // const lyrics = await player.getLyrics(track, true); | src/structures/Node.ts:687 |
lyrics.getCurrent | public | (guildId : string , skipTrackSource : boolean ) => Promise <LyricsResult > | undefined | Get the lyrics of the current playing track Example const lyrics = await player.node.lyrics.getCurrent(guildId); // use it of player instead: // const lyrics = await player.getCurrentLyrics(); | src/structures/Node.ts:716 |
lyrics.subscribe | public | (guildId : string ) => Promise <unknown > | undefined | subscribe to lyrics updates for a guild Example await player.node.lyrics.subscribe(guildId); // use it of player instead: // const lyrics = await player.subscribeLyrics(); | src/structures/Node.ts:745 |
lyrics.unsubscribe | public | (guildId : string ) => Promise <void > | undefined | unsubscribe from lyrics updates for a guild Example await player.node.lyrics.unsubscribe(guildId); // use it of player instead: // const lyrics = await player.unsubscribeLyrics(); | src/structures/Node.ts:773 |
options | public | LavalinkNodeOptions | undefined | The provided Options of the Node | src/structures/Node.ts:29 |
resuming | public | object | undefined | Wether the node resuming is enabled or not | src/structures/Node.ts:57 |
resuming.enabled | public | boolean | undefined | - | src/structures/Node.ts:57 |
resuming.timeout | public | number | undefined | - | src/structures/Node.ts:57 |
routePlannerApi | public | object | undefined | Lavalink’s Route Planner Api | src/structures/Node.ts:836 |
routePlannerApi.getStatus | public | () => Promise <RoutePlanner > | undefined | Get routplanner Info from Lavalink for ip rotation Example const routePlannerStatus = await player.node.routePlannerApi.getStatus(); const usedBlock = routePlannerStatus.details?.ipBlock; const currentIp = routePlannerStatus.currentAddress; | src/structures/Node.ts:848 |
routePlannerApi.unmarkAllFailedAddresses | public | () => Promise <unknown > | undefined | Release all blacklisted IP addresses into pool of IPs Example await player.node.routePlannerApi.unmarkAllFailedAddresses(); | src/structures/Node.ts:882 |
routePlannerApi.unmarkFailedAddress | public | (address : string ) => Promise <unknown > | undefined | Release blacklisted IP address into pool of IPs for ip rotation Example await player.node.routePlannerApi.unmarkFailedAddress("ipv6address"); | src/structures/Node.ts:863 |
sessionId? | public | string | null | The current sessionId, only present when connected | src/structures/Node.ts:55 |
stats | public | NodeStats | undefined | Stats from lavalink, will be updated via an interval by lavalink. | src/structures/Node.ts:33 |
Accessors
connected
Returns if connected to the Node.
Example
Returns
boolean
Defined in
connectionStatus
Returns the current ConnectionStatus
Example
Returns
string
Defined in
heartBeatPing
Returns
number
Defined in
id
Get the id of the node
Example
Returns
string
Defined in
Methods
connect()
Connect to the Lavalink Node
Parameters
Parameter | Type | Description |
---|---|---|
sessionId ? | string | Provide the Session Id of the previous connection, to resume the node and it’s player(s) |
Returns
void
void
Example
Defined in
deleteSponsorBlock()
Delete the sponsorblock plugins
Parameters
Parameter | Type | Description |
---|---|---|
player | Player | passthrough the player |
Returns
Promise
<void
>
void
Example
Defined in
destroy()
Destroys the Node-Connection (Websocket) and all player’s of the node
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
destroyReason ? | string | undefined | Destroy Reason to use when destroying the players |
deleteNode ? | boolean | true | wether to delete the nodte from the nodes list too, if false it will emit a disconnect. |
Returns
void
void
Default
Example
Defined in
destroyPlayer()
Destroys the Player on the Lavalink Server
Parameters
Parameter | Type | Description |
---|---|---|
guildId | any |
Returns
Promise
<void
>
request result
Example
Defined in
disconnect()
Disconnects the Node-Connection (Websocket)
Parameters
Parameter | Type | Description |
---|---|---|
disconnectReason ? | string | Disconnect Reason to use when disconnecting Node |
Returns
void
void
Also the node will not get re-connected again.
Example
Defined in
fetchAllPlayers()
Gets all Players of a Node
Returns
Promise
<LavalinkPlayer
[] | InvalidLavalinkRestRequest
>
array of players inside of lavalink
Example
Defined in
fetchInfo()
Request Lavalink information.
Returns
Promise
<LavalinkInfo
>
lavalink info object
Example
Defined in
fetchPlayer()
Gets specific Player Information
Parameters
Parameter | Type |
---|---|
guildId | string |
Returns
Promise
<LavalinkPlayer
| InvalidLavalinkRestRequest
>
lavalink player object if player exists on lavalink
Example
Defined in
fetchStats()
Request Lavalink statistics.
Returns
Promise
<BaseNodeStats
>
the lavalink node stats
Example
Defined in
fetchVersion()
Request Lavalink version.
Returns
Promise
<string
>
the current used lavalink version
Example
Defined in
getSponsorBlock()
Get the current sponsorblocks for the sponsorblock plugin
Parameters
Parameter | Type | Description |
---|---|---|
player | Player | passthrough the player |
Returns
Promise
<SponsorBlockSegment
[]>
sponsorblock seggment from lavalink
Example
Defined in
lavaSearch()
Search something using the lavaSearchPlugin (filtered searches by types)
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
query | LavaSearchQuery | undefined | LavaSearchQuery Object |
requestUser | unknown | undefined | Request User for creating the player(s) |
throwOnEmpty | boolean | false | Wether to throw on an empty result or not |
Returns
Promise
<LavaSearchResponse
| SearchResult
>
LavaSearchresult (SearchResult if link is provided)
Example
Defined in
request()
request(endpoint, modify, parseAsText)
Makes an API call to the Node. Should only be used for manual parsing like for not supported plugins
Parameters
Parameter | Type | Description |
---|---|---|
endpoint | string | The endpoint that we will make the call to |
modify | ModifyRequest | Used to modify the request before being sent |
parseAsText | true | - |
Returns
Promise
<string
>
The returned data
Example
Defined in
request(endpoint, modify, parseAsText)
Parameters
Parameter | Type |
---|---|
endpoint | string |
modify ? | ModifyRequest |
parseAsText ? | false |
Returns
Promise
<any
>
Defined in
search()
Search something raw on the node, please note only add tracks to players of that node
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
query | SearchQuery | undefined | SearchQuery Object |
requestUser | unknown | undefined | Request User for creating the player(s) |
throwOnEmpty | boolean | false | Wether to throw on an empty result or not |
Returns
Promise
<SearchResult
>
Searchresult
Example
Defined in
setSponsorBlock()
Set the current sponsorblocks for the sponsorblock plugin
Parameters
Parameter | Type | Description |
---|---|---|
player | Player | passthrough the player |
segments | SponsorBlockSegment [] | - |
Returns
Promise
<void
>
void
Example
Defined in
updatePlayer()
Update the Player State on the Lavalink Server
Parameters
Parameter | Type | Description |
---|---|---|
data | PlayerUpdateInfo | data to send to lavalink and sync locally |
Returns
Promise
<LavalinkPlayer
>
result from lavalink
Example
Defined in
updateSession()
Updates the session with and enables/disables resuming and timeout
Parameters
Parameter | Type | Description |
---|---|---|
resuming ? | boolean | Whether resuming is enabled for this session or not |
timeout ? | number | The timeout in seconds (default is 60s) |
Returns
Promise
<InvalidLavalinkRestRequest
| Session
>
the result of the request