Skip to main content
Version: v2.0.0

LavaShark

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new LavaShark(options)

Create a new LavaShark instance

Parameters

NameTypeDescription
optionsLavaSharkOptionsThe LavaShark options

Defined in

lib/LavaShark.ts:109

Properties

clientId

clientId: string

Defined in

lib/LavaShark.ts:28


nodes

nodes: Node[]

Defined in

lib/LavaShark.ts:29


players

players: Map<string, Player>

<guildId, Player>

Defined in

lib/LavaShark.ts:30


sendWS

Readonly sendWS: (guildId: string, payload: OutgoingDiscordPayload) => void

Example

sendWS: (guildId, payload) => {
client.guilds.cache.get(guildId)?.shard.send(payload);
}

Type declaration

▸ (guildId, payload): void

Parameters
NameTypeDescription
guildIdstringguildId
payloadOutgoingDiscordPayloadpayload
Returns

void

Defined in

lib/LavaShark.ts:51


unresolvedSearchSource

Readonly unresolvedSearchSource: SEARCH_SOURCE

Defined in

lib/LavaShark.ts:37


useISRC

Readonly useISRC: boolean

Defined in

lib/LavaShark.ts:38

Methods

addExternalSource

addExternalSource(extSource): void

Adds an external source that produces a SearchResult with UnresolvedTracks

Parameters

NameTypeDescription
extSourceAbstractExternalSourceThe external source

Returns

void

Defined in

lib/LavaShark.ts:186


bestNode

bestNode(): Promise<Node>

Get the best available node

Returns

Promise<Node>

Defined in

lib/LavaShark.ts:151


createPlayer

createPlayer(options): Player

Creates a new player or returns an existing one

Parameters

NameTypeDescription
optionsPlayerOptionsThe player options

Returns

Player

Defined in

lib/LavaShark.ts:247


decodeTrack

decodeTrack(encoded): Promise<Track>

Decodes a track by its base64 string

Parameters

NameTypeDescription
encodedstringThe base64 encoded track

Returns

Promise<Track>

Defined in

lib/LavaShark.ts:199


decodeTracks

decodeTracks(encodedTracks): Promise<Track[]>

Decodes multiple tracks by their base64 string

Parameters

NameTypeDescription
encodedTracksstring[]The base64 encoded tracks

Returns

Promise<Track[]>

Defined in

lib/LavaShark.ts:211


getPlayer

getPlayer(guildId): null | Player

Retrieve an existing player using the guild id

Parameters

NameTypeDescription
guildIdstringThe guild id that player belongs to

Returns

null | Player

Defined in

lib/LavaShark.ts:265


handleVoiceUpdate

handleVoiceUpdate(payload): void

Handles voice state & voice server update packets

Parameters

NameTypeDescription
payloadIncomingDiscordPayloadThe voice packet

Returns

void

Defined in

lib/LavaShark.ts:368


nodePing

nodePing(node, timeout?): Promise<number>

Get the ping for a single node

Parameters

NameTypeDefault valueDescription
nodeNodeundefinedThe node to ping
timeoutnumber1500Timeout value in milliseconds

Returns

Promise<number>

  • Node latency, in milliseconds

Defined in

lib/LavaShark.ts:424


nodesPing

nodesPing(timeout?): Promise<number[]>

Get the ping for all nodes

Parameters

NameTypeDefault valueDescription
timeoutnumber1500Timeout value in milliseconds

Returns

Promise<number[]>

  • All node latency, in milliseconds

Defined in

lib/LavaShark.ts:437


search(query, source?): Promise<SearchResult>

Search by song name or use music URL

Parameters

NameTypeDescription
querystringThe query to search for
source?SEARCH_SOURCEThe search source

Returns

Promise<SearchResult>

Defined in

lib/LavaShark.ts:286


start

start(clientId): void

Connects to all lavalink nodes

Parameters

NameTypeDescription
clientIdstringThe client id (BOT)

Returns

void

Defined in

lib/LavaShark.ts:349


checkOptions

Static checkOptions(options): void

Parameters

NameType
optionsLavaSharkOptions

Returns

void

Defined in

lib/LavaShark.ts:53