constvoice:object
Defined in: sdk/js/src/voice.ts:35
The bot’s voice stay and player. Errors throw ZaunError (FORBIDDEN without grants).
Type Declaration
Section titled “Type Declaration”clearQueue()
Section titled “clearQueue()”clearQueue():
void
Empties the queue; unlike stop, the current track keeps playing.
Returns
Section titled “Returns”void
endStream()
Section titled “endStream()”endStream():
void
The pushed track ends once its buffer has played.
Returns
Section titled “Returns”void
enqueue()
Section titled “enqueue()”enqueue(
t):number
Adds to the queue (≤ 100); returns its length.
Parameters
Section titled “Parameters”string | TrackOptions
Returns
Section titled “Returns”number
join()
Section titled “join()”join(
channelId):void
Joins a voice channel (leaving another first); returns once audio can flow.
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
Returns
Section titled “Returns”void
leave()
Section titled “leave()”leave():
void
Leaves; playback stops and the queue clears.
Returns
Section titled “Returns”void
moveTrack()
Section titled “moveTrack()”moveTrack(
from,to):void
Moves the queued track at from to to (both 0-based); the tracks between shift.
Parameters
Section titled “Parameters”number
number
Returns
Section titled “Returns”void
pause()
Section titled “pause()”pause():
void
Returns
Section titled “Returns”void
play()
Section titled “play()”play(
t):void
Plays now, replacing the current track (a string is a URL).
Parameters
Section titled “Parameters”string | TrackOptions
Returns
Section titled “Returns”void
push()
Section titled “push()”push(
packets):number
Opus packets for the current pushed track; returns ms buffered (BUSY past 3 s).
Parameters
Section titled “Parameters”packets
Section titled “packets”Uint8Array<ArrayBufferLike>[]
Returns
Section titled “Returns”number
remove()
Section titled “remove()”remove(
index):string
Removes the queued track at index (0 plays next); returns its title. Throws NOT_FOUND
past the end. Like every queue call, UNSUPPORTED on hosts without queue control.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”string
resume()
Section titled “resume()”resume():
void
Returns
Section titled “Returns”void
seek()
Section titled “seek()”seek(
ms):void
Jumps to ms into the current track; past the end, the track ends. Throws UNSUPPORTED for
live streams and pushed audio, and on hosts that cannot seek; CONFLICT when nothing plays.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
setLoop()
Section titled “setLoop()”setLoop(
mode):void
Sets what happens when a track ends.
Parameters
Section titled “Parameters”LoopMode
Returns
Section titled “Returns”void
setVolume()
Section titled “setVolume()”setVolume(
percent):void
Sets the playback volume, 0–200 % (100 when the bot joins). Throws ZaunError BAD_REQUEST
(detail percent) outside 0–200, checked before the call, and UNSUPPORTED on hosts without
an Opus encoder, which is most of them for now: tell the member and go on.
Parameters
Section titled “Parameters”percent
Section titled “percent”number
Returns
Section titled “Returns”void
shuffle()
Section titled “shuffle()”shuffle():
void
Puts the queue in a random order; the current track keeps playing.
Returns
Section titled “Returns”void
skip()
Section titled “skip()”skip():
void
Returns
Section titled “Returns”void
state()
Section titled “state()”state():
VoiceState
Returns
Section titled “Returns”stop()
Section titled “stop()”stop():
void
Ends the current track and clears the queue.
Returns
Section titled “Returns”void