LavaShark
Table of contents
Constructors
Properties
Methods
- addExternalSource
- bestNode
- createPlayer
- decodeTrack
- decodeTracks
- getPlayer
- handleVoiceUpdate
- nodePing
- nodesPing
- search
- start
- checkOptions
Constructors
constructor
• new LavaShark(options
)
Create a new LavaShark instance
Parameters
Name | Type | Description |
---|---|---|
options | LavaSharkOptions | The LavaShark options |
Defined in
Properties
clientId
• clientId: string
Defined in
nodes
• nodes: Node
[]
Defined in
on
• on: EventListeners
<LavaShark
>
Defined in
once
• once: EventListeners
<LavaShark
>
Defined in
players
• players: Map
<string
, Player
>
<guildId, Player>
Defined in
sendWS
• Readonly
sendWS: (guildId
: string
, payload
: OutgoingDiscordPayload
) => void
Type declaration
▸ (guildId
, payload
): void
Parameters
Name | Type | Description |
---|---|---|
guildId | string | guildId |
payload | OutgoingDiscordPayload | payload |
Returns
void
Example
sendWS: (guildId, payload) => {
client.guilds.cache.get(guildId)?.shard.send(payload);
}
Defined in
unresolvedSearchSource
• Readonly
unresolvedSearchSource: SEARCH_SOURCE
Defined in
useISRC
• Readonly
useISRC: boolean
Defined in
Methods
addExternalSource
▸ addExternalSource(extSource
): void
Adds an external source that produces a SearchResult with UnresolvedTracks
Parameters
Name | Type | Description |
---|---|---|
extSource | AbstractExternalSource | The external source |
Returns
void
Defined in
bestNode
▸ bestNode(): Promise
<Node
>
Returns
Promise
<Node
>
Defined in
createPlayer
▸ createPlayer(options
): Player
Creates a new player or returns an existing one
Parameters
Name | Type | Description |
---|---|---|
options | PlayerOptions | The player options |
Returns
Defined in
decodeTrack
▸ decodeTrack(encodedTrack
): Promise
<Track
>
Decodes a track by its base64 string
Parameters
Name | Type | Description |
---|---|---|
encodedTrack | string | The base64 encoded track |
Returns
Promise
<Track
>
Defined in
decodeTracks
▸ decodeTracks(encodedTracks
): Promise
<Track
[]>
Decodes multiple tracks by their base64 string
Parameters
Name | Type | Description |
---|---|---|
encodedTracks | string [] | The base64 encoded tracks |
Returns
Promise
<Track
[]>
Defined in
getPlayer
▸ getPlayer(guildId
): null
| Player
Retrieve an existing player using the guild id
Parameters
Name | Type | Description |
---|---|---|
guildId | string | The guild id that player belongs to |
Returns
null
| Player
Defined in
handleVoiceUpdate
▸ handleVoiceUpdate(payload
): void
Handles voice state & voice server update packets
Parameters
Name | Type | Description |
---|---|---|
payload | IncomingDiscordPayload | The voice packet |
Returns
void
Defined in
nodePing
▸ nodePing(node
, timeout?
): Promise
<number
>
Get the ping for a single node
Parameters
Name | Type | Default value | Description |
---|---|---|---|
node | Node | undefined | The node to ping |
timeout | number | 1500 | Timeout value in milliseconds |
Returns
Promise
<number
>
- Node latency, in milliseconds
Defined in
nodesPing
▸ nodesPing(timeout?
): Promise
<number
[]>
Get the ping for all nodes
Parameters
Name | Type | Default value | Description |
---|---|---|---|
timeout | number | 1500 | Timeout value in milliseconds |
Returns
Promise
<number
[]>
- All node latency, in milliseconds
Defined in
search
▸ search(query
, source?
): Promise
<SearchResult
>
Search by song name or use music URL
Parameters
Name | Type | Description |
---|---|---|
query | string | The query to search for |
source? | SEARCH_SOURCE | The search source |
Returns
Promise
<SearchResult
>
Defined in
start
▸ start(clientId
): void
Connects to all lavalink nodes
Parameters
Name | Type | Description |
---|---|---|
clientId | string | The client id (BOT) |
Returns
void
Defined in
checkOptions
▸ Static
checkOptions(options
): void
Parameters
Name | Type |
---|---|
options | LavaSharkOptions |
Returns
void