Skip to main content
Version: v1.2.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:114

Properties

clientId

clientId: string

Defined in

lib/LavaShark.ts:31


nodes

nodes: Node[]

Defined in

lib/LavaShark.ts:32


on

on: EventListeners<LavaShark>

Defined in

lib/LavaShark.ts:27


once

once: EventListeners<LavaShark>

Defined in

lib/LavaShark.ts:26


players

players: Map<string, Player>

<guildId, Player>

Defined in

lib/LavaShark.ts:41


sendWS

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

Type declaration

▸ (guildId, payload): void

Example

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

void

Defined in

lib/LavaShark.ts:56


unresolvedSearchSource

Readonly unresolvedSearchSource: SEARCH_SOURCE

Defined in

lib/LavaShark.ts:35


useISRC

Readonly useISRC: boolean

Defined in

lib/LavaShark.ts:36

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:181


bestNode

bestNode(): Promise<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:224


decodeTrack

decodeTrack(encodedTrack): Promise<Track>

Decodes a track by its base64 string

Parameters

NameTypeDescription
encodedTrackstringThe base64 encoded track

Returns

Promise<Track>

Defined in

lib/LavaShark.ts:194


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:206


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:242


handleVoiceUpdate

handleVoiceUpdate(payload): void

Handles voice state & voice server update packets

Parameters

NameTypeDescription
payloadIncomingDiscordPayloadThe voice packet

Returns

void

Defined in

lib/LavaShark.ts:323


nodesPing

nodesPing(): Promise<number[]>

Get the ping for all nodes

Returns

Promise<number[]>

  • All node latency, in milliseconds

Defined in

lib/LavaShark.ts:377


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:263


start

start(clientId): void

Connects to all lavalink nodes

Parameters

NameTypeDescription
clientIdstringThe client id (BOT)

Returns

void

Defined in

lib/LavaShark.ts:307


checkOptions

Static checkOptions(options): void

Parameters

NameType
optionsLavaSharkOptions

Returns

void

Defined in

lib/LavaShark.ts:58