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

Player

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Player(lavashark, options)

創建一個 Player 實例

Parameters

NameTypeDescription
lavasharkLavaSharkLavaShark 實例
optionsPlayerOptionsPlayer 選項

Defined in

lib/Player.ts:88

Properties

current

current: null | Track

Defined in

lib/Player.ts:48


filters

Readonly filters: Filters

Defined in

lib/Player.ts:38


guildId

Readonly guildId: string

Defined in

lib/Player.ts:37


moving

moving: boolean

Defined in

lib/Player.ts:61


node

node: null | Node

Defined in

lib/Player.ts:40


paused

paused: boolean

Defined in

lib/Player.ts:56


playing

playing: boolean

Defined in

lib/Player.ts:55


position

position: number

Defined in

lib/Player.ts:53


queue

queue: Queue

Defined in

lib/Player.ts:49


repeatMode

repeatMode: RepeatMode

Defined in

lib/Player.ts:51


selfDeaf

Optional selfDeaf: boolean

Defined in

lib/Player.ts:45


selfMute

Optional selfMute: boolean

Defined in

lib/Player.ts:46


state

state: ConnectionState

Defined in

lib/Player.ts:58


textChannelId

Optional textChannelId: null | string

Defined in

lib/Player.ts:43


voiceChannelId

voiceChannelId: string

Defined in

lib/Player.ts:42


voiceState

voiceState: VoiceState

Defined in

lib/Player.ts:59

Accessors

exactPosition

get exactPosition(): number

根據上次 playerUpdate 數據包獲取準確的 track 位置

Returns

number

Defined in

lib/Player.ts:127


queueDuration

get queueDuration(): number

獲取隊列的持續時間,以毫秒為單位

Returns

number

Deprecated

  • Use queue.duration instead

Defined in

lib/Player.ts:142


volume

get volume(): number

獲取播放器的音量

Returns

number

Defined in

lib/Player.ts:149

Methods

addTracks

addTracks(tracks, requester): void

將一個或多個歌曲添加到隊列

Parameters

NameTypeDescription
tracksdefaultTrack
requesterunknown歌曲的請求者

Returns

void

Defined in

lib/Player.ts:169


connect

connect(): Promise<void>

連接到語音頻道

Returns

Promise<void>

Defined in

lib/Player.ts:188


destroy

destroy(): void

摧毀 Player

Returns

void

Defined in

lib/Player.ts:229


disconnect

disconnect(): void

與語音通道斷開連接

Returns

void

Defined in

lib/Player.ts:210


moveNode

moveNode(node): Promise<void>

Parameters

NameTypeDescription
nodeNode將 Player 移動到的目標節點

Returns

Promise<void>

Defined in

lib/Player.ts:247


pause

pause(state?): Promise<boolean>

暫停或取消暫停 Player

Parameters

NameTypeDefault valueDescription
state?booleantrue是暫停還是取消暫停 Player

Returns

Promise<boolean>

Defined in

lib/Player.ts:370


ping

ping(): Promise<number>

獲取 Lavalink 客戶端與節點之間的延遲

Returns

Promise<number>

  • 以毫秒為單位

Defined in

lib/Player.ts:286


play

play(options?): Promise<void>

播放曲目

Parameters

NameTypeDescription
options?PlayOptionsPlay options

Returns

Promise\<void>

Defined in

lib/Player.ts:308


prioritizePlay

prioritizePlay(track, requester): Promise\<boolean>

優先播放新曲目

Parameters

NameTypeDescription
trackTrack要優先播放的曲目
requesterUser歌曲的請求者

Returns

Promise<void>

Defined in

lib/Player.ts:347


resume

resume(): Promise<boolean>

恢復播放

Returns

Promise\<boolean>

Defined in

lib/Player.ts:394


seek

seek(position): Promise<void>

在音軌中跳轉到特定位置

Parameters

NameTypeDescription
positionnumberThe position to seek, in milliseconds

Returns

Promise<void>

Defined in

lib/Player.ts:430


sendVoiceUpdate

sendVoiceUpdate(): Promise<void>

Returns

Promise<void>

Defined in

lib/Player.ts:527


setRepeatMode

setRepeatMode(mode): void

為這個隊列設置重複模式

Parameters

NameTypeDescription
modeRepeatMode要設置的重複模式

Returns

void

Defined in

lib/Player.ts:450


setSelfDeaf

setSelfDeaf(state): void

設置機器人的自身拒聽狀態

Parameters

NameTypeDescription
stateboolean是否拒聽

Returns

void

Defined in

lib/Player.ts:492


setSelfMute

setSelfMute(state): void

設置機器人的自身靜音狀態

Parameters

NameTypeDescription
stateboolean是否靜音

Returns

void

Defined in

lib/Player.ts:505


setVoiceChannel

setVoiceChannel(channelId): void

設置 Player 的語音頻道

Parameters

NameTypeDescription
channelIdstring語音頻道 ID

Returns

void

Defined in

lib/Player.ts:518


skip

skip(amount?): Promise<boolean>

跳過正在播放的歌曲

Parameters

NameTypeDescription
amount?number要跳過的歌曲數量

Returns

Promise<boolean>

Defined in

lib/Player.ts:402


update

update(state): void

Update player state

Parameters

NameTypeDescription
statePlayerStateplayerUpdate event

Returns

void

Inner

Defined in

lib/Player.ts:550


checkOptions

checkOptions(options): void

Parameters

NameType
optionsPlayerOptions

Returns

void

Defined in

lib/Player.ts:66