pub struct Voice;Expand description
The bot’s voice: one stay at a time.
Implementations§
Source§impl Voice
impl Voice
Source§impl Voice
impl Voice
Sourcepub fn remove(index: u32) -> Result<Option<String>, HostError>
pub fn remove(index: u32) -> Result<Option<String>, HostError>
Removes the queued track at index (0 plays next); returns its title.
§Errors
NOT_FOUND past the end of the queue; UNSUPPORTED on hosts without queue control.
Sourcepub fn move_track(from: u32, to: u32) -> Result<(), HostError>
pub fn move_track(from: u32, to: u32) -> Result<(), HostError>
Moves the queued track at from to to (both 0-based); the tracks between shift.
§Errors
NOT_FOUND past the end of the queue; UNSUPPORTED on hosts without queue control.
Sourcepub fn shuffle() -> Result<(), HostError>
pub fn shuffle() -> Result<(), HostError>
Puts the queue in a random order; the current track keeps playing.
§Errors
UNSUPPORTED on hosts without queue control.
Sourcepub fn clear_queue() -> Result<(), HostError>
pub fn clear_queue() -> Result<(), HostError>
Empties the queue; unlike Voice::stop, the current track keeps playing.
§Errors
UNSUPPORTED on hosts without queue control.
Source§impl Voice
impl Voice
Sourcepub fn join(channel: &str) -> Result<(), HostError>
pub fn join(channel: &str) -> Result<(), HostError>
Joins voice channel channel (leaving another one); returns once audio can flow.
§Errors
NOT_GRANTED without the voice capability; FORBIDDEN without CONNECT/SPEAK.
Sourcepub fn play_url(url: &str, title: Option<&str>) -> Result<(), HostError>
pub fn play_url(url: &str, title: Option<&str>) -> Result<(), HostError>
Plays an Ogg Opus file or stream now, replacing the current track: an https:// URL
on a network host, or an http:///https:// URL on a local_network address. The
SDK passes the URL through; the host checks it.
§Errors
CONFLICT when not in a voice channel; an address outside the grants shows up as a
TrackError event when the track starts.
Sourcepub fn enqueue_url(url: &str, title: Option<&str>) -> Result<u32, HostError>
pub fn enqueue_url(url: &str, title: Option<&str>) -> Result<u32, HostError>
Queues an Ogg Opus file or stream (as Voice::play_url); returns the queue’s length.
§Errors
As Voice::play_url; CONFLICT with limit_reached past 100 tracks.
Sourcepub fn start_stream(title: Option<&str>) -> Result<(), HostError>
pub fn start_stream(title: Option<&str>) -> Result<(), HostError>
Starts a track the bot feeds with Voice::push_opus until Voice::end_stream.
§Errors
As Voice::play_url.
Sourcepub fn push_opus(packets: &[Vec<u8>]) -> Result<u32, HostError>
pub fn push_opus(packets: &[Vec<u8>]) -> Result<u32, HostError>
Opus packets (2.5–120 ms each, ≤ 1000 bytes) for the current stream; returns the ms buffered. Push about as fast as it plays.
§Errors
BUSY past 3 s buffered (push again later); CONFLICT without a stream track.
Sourcepub fn end_stream()
pub fn end_stream()
Ends the stream track once its buffered packets have played.
Sourcepub fn state() -> VoiceState
pub fn state() -> VoiceState
Where the bot is and what it plays.