LavaShark
Table of contents
Constructors
Properties
Methods
- addExternalSource
- bestNode
- createPlayer
- decodeTrack
- decodeTracks
- getPlayer
- handleVoiceUpdate
- 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
Example
sendWS: (guildId, payload) => {
client.guilds.cache.get(guildId)?.shard.send(payload);
}
Parameters
Name | Type | Description |
---|---|---|
guildId | string | guildId |
payload | OutgoingDiscordPayload | payload |
Returns
void
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
nodesPing
▸ nodesPing(): Promise
<number
[]>
Get the ping for all nodes
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