跳至主要内容
版本:v2.1.0

LavaShark

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new LavaShark(options)

創建一個 LavaShark 實例

Parameters

NameTypeDescription
optionsLavaSharkOptionsLavaShark 選項

Returns

LavaShark

Overrides

EventEmitter.constructor

Defined in

lib/LavaShark.ts:109

Properties

clientId

clientId: string

Defined in

lib/LavaShark.ts:28


nodes

nodes: Node[]

Defined in

lib/LavaShark.ts:29


players

players: Map<string, Player>

<guildId, Player>

Defined in

lib/LavaShark.ts:30


sendWS

Readonly sendWS: (guildId: string, payload: OutgoingDiscordPayload) => void

範例

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

Type declaration

▸ (guildId, payload): void

Parameters
NameTypeDescription
guildIdstringguildId
payloadOutgoingDiscordPayloadpayload
Returns

void

Defined in

lib/LavaShark.ts:51


unresolvedSearchSource

Readonly unresolvedSearchSource: SEARCH_SOURCE

Defined in

lib/LavaShark.ts:37


useISRC

Readonly useISRC: boolean

Defined in

lib/LavaShark.ts:38

Methods

addExternalSource

addExternalSource(extSource): void

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

Parameters

NameTypeDescription
extSourceAbstractExternalSource外部來源

Returns

void

Defined in

lib/LavaShark.ts:198


bestNode

bestNode(): Promise<Node>

取得最佳可用節點

Returns

Promise<Node>

Defined in

lib/LavaShark.ts:163


createPlayer

createPlayer(options): Player

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

Parameters

NameTypeDescription
optionsPlayerOptionsThe player options

Returns

Player

Defined in

lib/LavaShark.ts:269


decodeTrack

decodeTrack(encoded): Promise<Track>

解碼以 base64 字串表示的音軌

Parameters

NameTypeDescription
encodedstring該音軌的 base64 編碼

Returns

Promise<Track>

Defined in

lib/LavaShark.ts:211


decodeTracks

decodeTracks(encodedTracks): Promise<Track[]>

解碼多個音軌的 base64 字串

Parameters

NameTypeDescription
encodedTracksstring[]The base64 encoded tracks

Returns

Promise<Track[]>

Defined in

lib/LavaShark.ts:223


emit

emit\<EventName>(event, ...args): boolean

Type parameters

NameType
EventNameextends keyof LavaSharkEvents

Parameters

NameType
eventEventName
...argsParameters\<LavaSharkEvents[EventName]>

Returns

boolean

Overrides

EventEmitter.emit

Defined in

lib/LavaShark.ts:146


getPlayer

getPlayer(guildId): null | Player

使用 guild ID 檢索現有的 Player

Parameters

NameTypeDescription
guildIdstring該 Player 所屬的 guild ID

Returns

null | Player

Defined in

lib/LavaShark.ts:287


handleVoiceUpdate

handleVoiceUpdate(payload): void

Handles voice state & voice server update packets

Parameters

NameTypeDescription
payloadIncomingDiscordPayloadThe voice packet

Returns

void

Defined in

lib/LavaShark.ts:390


nodePing

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

獲取單個節點的 ping 值

Parameters

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

Returns

Promise<number>

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

Defined in

lib/LavaShark.ts:446


nodesPing

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

獲取所有節點的 ping 值

Parameters

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

Returns

Promise<number[]>

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

Defined in

lib/LavaShark.ts:459


on

on\<EventName>(event, listener): this

Type parameters

NameType
EventNameextends keyof LavaSharkEvents

Parameters

NameType
eventEventName
listenerLavaSharkEvents[EventName]

Returns

this

Overrides

EventEmitter.on

Defined in

lib/LavaShark.ts:150


once

once\<EventName>(event, listener): this

Type parameters

NameType
EventNameextends keyof LavaSharkEvents

Parameters

NameType
eventEventName
listenerLavaSharkEvents[EventName]

Returns

this

Overrides

EventEmitter.once

Defined in

lib/LavaShark.ts:154


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

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

Parameters

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

Returns

Promise<SearchResult>

Defined in

lib/LavaShark.ts:308


start

start(clientId): void

連接到所有 Lavalink 節點

Parameters

NameTypeDescription
clientIdstringclient ID (BOT)

Returns

void

Defined in

lib/LavaShark.ts:371


checkOptions

Static checkOptions(options): void

Parameters

NameType
optionsLavaSharkOptions

Returns

void

Defined in

lib/LavaShark.ts:53