Skip to main content
Version: v1.3.3

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

Parameters
NameTypeDescription
guildIdstringguildId
payloadOutgoingDiscordPayloadpayload
Returns

void

Example

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

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


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


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


handleVoiceUpdate

handleVoiceUpdate(payload): void

Handles voice state & voice server update packets

Parameters

NameTypeDescription
payloadIncomingDiscordPayloadThe voice packet

Returns

void

Defined in

lib/LavaShark.ts:328


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


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


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


start

start(clientId): void

Connects to all lavalink nodes

Parameters

NameTypeDescription
clientIdstringThe client id (BOT)

Returns

void

Defined in

lib/LavaShark.ts:312


checkOptions

Static checkOptions(options): void

Parameters

NameType
optionsLavaSharkOptions

Returns

void

Defined in

lib/LavaShark.ts:58