LavaShark
Table of contents
Constructors
Properties
Methods
- addExternalSource
- bestNode
- createPlayer
- decodeTrack
- decodeTracks
- getPlayer
- handleVoiceUpdate
- 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
Example
sendWS: (guildId, payload) => {
client.guilds.cache.get(guildId)?.shard.send(payload);
}
Parameters
Name | Type | Description |
---|---|---|
guildId | string | guildId |
payload | OutgoingDiscordPayload | payload |
Returns
void
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 | Player 選項 |
Returns
Defined in
decodeTrack
▸ decodeTrack(encodedTrack
): Promise
<Track
>
Decodes a track by its base64 string
Parameters
Name | Type | Description |
---|---|---|
encodedTrack | string | The base64 encoded track |
Returns
Promise
<Track
>
Defined in
decodeTracks
▸ decodeTracks(encodedTracks
): Promise
<Track
[]>
Decodes multiple tracks by their base64 string
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
nodesPing
▸ nodesPing(): Promise
<number
[]>
獲取所有節點的 ping 值
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