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 選項 |
Returns
Overrides
EventEmitter.constructor
Defined in
Properties
clientId
• clientId: string
Defined in
nodes
• nodes: Node
[]
Defined in
players
• players: Map
<string
, Player
>
<guildId, Player>
Defined in
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
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 | The player options |
Returns
Defined in
decodeTrack
▸ decodeTrack(encoded
): Promise
<Track
>
解碼以 base64 字串表示的音軌
Parameters
Name | Type | Description |
---|---|---|
encoded | 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
emit
▸ emit\<EventName
>(event
, ...args
): boolean
Type parameters
Name | Type |
---|---|
EventName | extends keyof LavaSharkEvents |
Parameters
Name | Type |
---|---|
event | EventName |
...args | Parameters \<LavaSharkEvents [EventName ]> |
Returns
boolean
Overrides
EventEmitter.emit
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
Handles voice state & voice server update packets
Parameters
Name | Type | Description |
---|---|---|
payload | IncomingDiscordPayload | The voice packet |
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
on
▸ on\<EventName
>(event
, listener
): this
Type parameters
Name | Type |
---|---|
EventName | extends keyof LavaSharkEvents |
Parameters
Name | Type |
---|---|
event | EventName |
listener | LavaSharkEvents [EventName ] |
Returns
this
Overrides
EventEmitter.on
Defined in
once
▸ once\<EventName
>(event
, listener
): this
Type parameters
Name | Type |
---|---|
EventName | extends keyof LavaSharkEvents |
Parameters
Name | Type |
---|---|
event | EventName |
listener | LavaSharkEvents [EventName ] |
Returns
this
Overrides
EventEmitter.once
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