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

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

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

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

Parameters

NameTypeDescription
extSourceAbstractExternalSource外部來源

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

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

Parameters

NameTypeDescription
optionsPlayerOptionsThe player options

Returns

Player

Defined in

lib/LavaShark.ts:229


decodeTrack

decodeTrack(encodedTrack): Promise<Track>

解碼以 base64 字串表示的音軌

Parameters

NameTypeDescription
encodedTrackstring該音軌的 base64 編碼

Returns

Promise<Track>

Defined in

lib/LavaShark.ts:199


decodeTracks

decodeTracks(encodedTracks): Promise<Track[]>

解碼多個音軌的 base64 字串

Parameters

NameTypeDescription
encodedTracksstring[]The base64 encoded tracks

Returns

Promise<Track[]>

Defined in

lib/LavaShark.ts:211


getPlayer

getPlayer(guildId): null | Player

使用 guild ID 檢索現有的 Player

Parameters

NameTypeDescription
guildIdstring該 Player 所屬的 guild ID

Returns

null | Player

Defined in

lib/LavaShark.ts:247


handleVoiceUpdate

handleVoiceUpdate(payload): void

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

Parameters

NameTypeDescription
payloadIncomingDiscordPayload語音封包

Returns

void

Defined in

lib/LavaShark.ts:328


nodePing

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

獲取單個節點的 ping 值

Parameters

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

Returns

Promise<number>

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

Defined in

lib/LavaShark.ts:384


nodesPing

nodesPing(timeout?): Promise<number[]>

獲取所有節點的 ping 值

Parameters

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

Returns

Promise<number[]>

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

Defined in

lib/LavaShark.ts:397


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

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

Parameters

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

Returns

Promise<SearchResult>

Defined in

lib/LavaShark.ts:268


start

start(clientId): void

連接到所有 Lavalink 節點

Parameters

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