LavaShark
Table of contents
Constructors
Properties
Methods
- addExternalSource
- bestNode
- createPlayer
- decodeTrack
- decodeTracks
- getPlayer
- handleVoiceUpdate
- nodePing
- nodesPing
- search
- start
- checkOptions
Constructors
constructor
• new LavaShark(options
)
創建一個 LavaShark 實例
Parameters
Name | Type | Description |
---|---|---|
options | LavaSharkOptions | LavaShark 選項 |
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
Parameters
Name | Type | Description |
---|---|---|
guildId | string | guildId |
payload | OutgoingDiscordPayload | payload |
Returns
void
Example
sendWS: (guildId, payload) => {
client.guilds.cache.get(guildId)?.shard.send(payload);
}
Defined in
unresolvedSearchSource
• Readonly
unresolvedSearchSource: SEARCH_SOURCE
Defined in
useISRC
• Readonly
useISRC: boolean
Defined in
Methods
addExternalSource
▸ addExternalSource(extSource
): void
添加一個外部來源,生成帶有 UnresolvedTracks 的 SearchResult
Parameters
Name | Type | Description |
---|---|---|
extSource | AbstractExternalSource | 外部來源 |
Returns
void
Defined in
bestNode
▸ bestNode(): Promise
<Node
>
Returns
Promise
<Node
>
Defined in
createPlayer
▸ createPlayer(options
): Player
創建一個新的 Player 或返回一個現有的 Player
Parameters
Name | Type | Description |
---|---|---|
options | PlayerOptions | The player options |
Returns
Defined in
decodeTrack
▸ decodeTrack(encodedTrack
): Promise
<Track
>
解碼以 base64 字串表示的音軌
Parameters
Name | Type | Description |
---|---|---|
encodedTrack | string | 該音軌的 base64 編碼 |
Returns
Promise
<Track
>
Defined in
decodeTracks
▸ decodeTracks(encodedTracks
): Promise
<Track
[]>
解碼多個音軌的 base64 字串
Parameters
Name | Type | Description |
---|---|---|
encodedTracks | string [] | The base64 encoded tracks |
Returns
Promise
<Track
[]>
Defined in
getPlayer
▸ getPlayer(guildId
): null
| Player
使用 guild ID 檢索現有的 Player
Parameters
Name | Type | Description |
---|---|---|
guildId | string | 該 Player 所屬的 guild ID |
Returns
null
| Player
Defined in
handleVoiceUpdate
▸ handleVoiceUpdate(payload
): void
處理語音狀態和語音伺服器更新封包
Parameters
Name | Type | Description |
---|---|---|
payload | IncomingDiscordPayload | 語音封包 |
Returns
void
Defined in
nodePing
▸ nodePing(node
, timeout?
): Promise
<number
>
獲取單個節點的 ping 值
Parameters
Name | Type | Default value | Description |
---|---|---|---|
node | Node | undefined | 要 ping 的節點 |
timeout | number | 1500 | 超時值,以毫秒為單位 |
Returns
Promise
<number
>
- 節點的延遲,以毫秒為單位
Defined in
nodesPing
▸ nodesPing(timeout?
): Promise
<number
[]>
獲取所有節點的 ping 值
Parameters
Name | Type | Default value | Description |
---|---|---|---|
timeout | number | 1500 | 超時值,以毫秒為單位 |
Returns
Promise
<number
[]>
- 所有節點的延遲,以毫秒為單位
Defined in
search
▸ search(query
, source?
): Promise
<SearchResult
>
通過歌曲名稱進行搜索或使用歌曲連結
Parameters
Name | Type | Description |
---|---|---|
query | string | 要搜索的內容 |
source? | SEARCH_SOURCE | 搜尋來源 |
Returns
Promise
<SearchResult
>
Defined in
start
▸ start(clientId
): void
連接到所有 Lavalink 節點
Parameters
Name | Type | Description |
---|---|---|
clientId | string | client ID (BOT) |
Returns
void
Defined in
checkOptions
▸ Static
checkOptions(options
): void
Parameters
Name | Type |
---|---|
options | LavaSharkOptions |
Returns
void