Skip to main content

Module voice

Module voice 

Source
Expand description

Voice channels (capability voice, ADR-0020). The host joins as the bot, end-to-end encrypted like any member, and plays audio for it in real time: the bot only says what to play. One stay per bot; CONNECT and SPEAK apply as for members. Nothing is transcoded, so audio is Opus: Ogg Opus files and streams (.opus, .ogg holding Opus), WebM Opus (audio/webm, YouTube’s itag 251) on hosts that demux it, or Opus packets the bot makes.

Structs§

Track
Something to play.
VoiceState

Enums§

LoopMode
What happens when a track ends: go on (off), play it again (track), or put it at the end of the queue (queue).
PlayerStatus
Source
Where a track’s audio comes from.
VoiceEvent
What happened, for on-voice-event.

Functions§

clear_queue
Empties the queue; the current track keeps playing.
end_stream
The pushed track ends once its buffered packets have played.
enqueue
Adds track to the queue (≤ 100); returns the queue’s length.
join
Joins voice channel channel (leaving another one first). Returns once media can flow (at most about 10 s). FORBIDDEN without voice, CONNECT or SPEAK.
leave
Leaves; playback stops and the queue is cleared.
move_
Moves the queued track at from to to (both 0-based); the tracks between shift. NOT_FOUND past the end.
pause
play
Plays track now, replacing the current one; the queue stays.
push
Opus packets (2.5 to 120 ms each, ≤ 1000 bytes) for the current pushed track. Returns the audio buffered, in ms; BUSY past 3 s, so push about as fast as it plays.
remove
Removes the queued track at index (0 plays next); returns its title. NOT_FOUND past the end.
resume
seek
Jumps to ms into the current track (past the end: the track ends). UNSUPPORTED for live streams and pushed audio, and on hosts that cannot seek; CONFLICT when nothing plays.
set_loop
Sets what happens when a track ends (off when the bot joins).
set_volume
Sets the playback volume, 0-200 % (100 when the bot joins; BAD_REQUEST above 200). Changing it means decoding and re-encoding the Opus audio, so hosts without an Opus encoder answer UNSUPPORTED: call it anyway and tell the member.
shuffle
Puts the queue in a random order (the current track keeps playing).
skip
Ends the current track; the next one starts.
state
Where the bot is and what it plays.
stop
Ends the current track and clears the queue.

Type Aliases§

HostError
Id