跳至主要内容
版本:v1.2.1

LavaShark

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new LavaShark(options)

創建一個 LavaShark 實例

Parameters

NameTypeDescription
optionsLavaSharkOptionsLavaShark 選項

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

添加一個外部來源,生成帶有 UnresolvedTracks 的 SearchResult

Parameters

NameTypeDescription
extSourceAbstractExternalSource外部來源

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

創建一個新的 Player 或返回一個現有的 Player

Parameters

NameTypeDescription
optionsPlayerOptionsPlayer 選項

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

使用 guild ID 檢索現有的 Player

Parameters

NameTypeDescription
guildIdstring該 Player 所屬的 guild ID

Returns

null | Player

Defined in

lib/LavaShark.ts:242


handleVoiceUpdate

handleVoiceUpdate(payload): void

處理語音狀態和語音伺服器更新封包

Parameters

NameTypeDescription
payloadIncomingDiscordPayload語音封包

Returns

void

Defined in

lib/LavaShark.ts:323


nodePing

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

獲取單個節點的 ping 值

Parameters

NameTypeDefault valueDescription
nodeNodeundefined要 ping 的節點
timeoutnumber1500超時值,以毫秒為單位

Returns

Promise<number>

  • 節點的延遲,以毫秒為單位

Defined in

lib/LavaShark.ts:377


nodesPing

nodesPing(): Promise<number[]>

獲取所有節點的 ping 值

Parameters

NameTypeDefault valueDescription
timeoutnumber1500超時值,以毫秒為單位

Returns

Promise<number[]>

  • 所有節點的延遲,以毫秒為單位

Defined in

lib/LavaShark.ts:407


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

通過歌曲名稱進行搜索或使用歌曲連結

Parameters

NameTypeDescription
querystring要搜索的內容
source?SEARCH_SOURCE搜尋來源

Returns

Promise<SearchResult>

Defined in

lib/LavaShark.ts:263


start

start(clientId): void

連接到所有 Lavalink 節點

Parameters

NameTypeDescription
clientIdstringclient 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