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

LavaShark

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new LavaShark(options)

創建一個 LavaShark 實例

Parameters

NameTypeDescription
optionsLavaSharkOptionsLavaShark 選項

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: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:247


decodeTrack

decodeTrack(encoded): Promise<Track>

解碼以 base64 字串表示的音軌

Parameters

NameTypeDescription
encodedstring該音軌的 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:265


handleVoiceUpdate

handleVoiceUpdate(payload): void

Handles voice state & voice server update packets

Parameters

NameTypeDescription
payloadIncomingDiscordPayloadThe voice packet

Returns

void

Defined in

lib/LavaShark.ts:368


nodePing

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

獲取單個節點的 ping 值

Parameters

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

Returns

Promise<number>

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

Defined in

lib/LavaShark.ts:424


nodesPing

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

獲取所有節點的 ping 值

Parameters

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

Returns

Promise<number[]>

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

Defined in

lib/LavaShark.ts:437


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

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

Parameters

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

Returns

Promise<SearchResult>

Defined in

lib/LavaShark.ts:286


start

start(clientId): void

連接到所有 Lavalink 節點

Parameters

NameTypeDescription
clientIdstringclient ID (BOT)

Returns

void

Defined in

lib/LavaShark.ts:349


checkOptions

Static checkOptions(options): void

Parameters

NameType
optionsLavaSharkOptions

Returns

void

Defined in

lib/LavaShark.ts:53