Struct songbird::Call[][src]

pub struct Call { /* fields omitted */ }

The Call handler is responsible for a single voice connection, acting as a clean API above the inner state and gateway message management.

If the "driver" feature is enabled, then a Call exposes all control methods of Driver via Deref(Mut).

Implementations

impl Call[src]

pub fn new(guild_id: GuildId, ws: Shard, user_id: UserId) -> Self[src]

Creates a new Call, which will send out WebSocket messages via the given shard.

pub fn from_driver_config(
    guild_id: GuildId,
    ws: Shard,
    user_id: UserId,
    config: Config
) -> Self
[src]

Creates a new Call, configuring the driver as specified.

pub fn standalone(guild_id: GuildId, user_id: UserId) -> Self[src]

Creates a new, standalone Call which is not connected via WebSocket to the Gateway.

Actions such as muting, deafening, and switching channels will not function through this Call and must be done through some other method, as the values will only be internally updated.

For most use cases you do not want this.

pub fn standalone_from_driver_config(
    guild_id: GuildId,
    user_id: UserId,
    config: Config
) -> Self
[src]

Creates a new standalone Call, configuring the driver as specified.

pub async fn deafen(&mut self, deaf: bool) -> JoinResult<()>[src]

Sets whether the current connection is to be deafened.

If there is no live voice connection, then this only acts as a settings update for future connections.

Note: Unlike in the official client, you can be deafened while not being muted.

Note: If the Call was created via standalone, then this will only update whether the connection is internally deafened.

pub fn is_deaf(&self) -> bool[src]

Returns whether the current connection is self-deafened in this server.

This is purely cosmetic.

pub async fn join(
    &mut self,
    channel_id: ChannelId
) -> JoinResult<RecvFut<'static, ConnectionResult<()>>>
[src]

Connect or switch to the given voice channel by its Id.

This function acts as a future in two stages:

  • The first await sends the request over the gateway.
  • The second awaits a the driver’s connection attempt. To prevent deadlock, any mutexes around this Call must be released before this result is queried.

When using Songbird::join, this pattern is correctly handled for you.

pub async fn join_gateway(
    &mut self,
    channel_id: ChannelId
) -> JoinResult<RecvFut<'static, ConnectionInfo>>
[src]

Join the selected voice channel, without running/starting an RTP session or running the driver.

Use this if you require connection info for lavalink, some other voice implementation, or don’t want to use the driver for a given call.

This function acts as a future in two stages:

  • The first await sends the request over the gateway.
  • The second awaits voice session data from Discord. To prevent deadlock, any mutexes around this Call must be released before this result is queried.

When using Songbird::join_gateway, this pattern is correctly handled for you.

pub fn current_connection(&self) -> Option<&ConnectionInfo>[src]

Returns the current voice connection details for this Call, if available.

pub fn current_channel(&self) -> Option<ChannelId>[src]

Returns id of the channel, if connected to any.

Note:: Returned id is of the channel, to which bot performed connection. It is possible that it is different from actual channel due to ability of server’s admin to move bot from channel to channel. This is to be fixed with next breaking change release.

pub async fn leave(&mut self) -> JoinResult<()>[src]

Leaves the current voice channel, disconnecting from it.

This does not forget settings, like whether to be self-deafened or self-muted.

Note: If the Call was created via standalone, then this will only update whether the connection is internally connected to a voice channel.

pub async fn mute(&mut self, mute: bool) -> JoinResult<()>[src]

Sets whether the current connection is to be muted.

If there is no live voice connection, then this only acts as a settings update for future connections.

Note: If the Call was created via standalone, then this will only update whether the connection is internally muted.

pub fn is_mute(&self) -> bool[src]

Returns whether the current connection is self-muted in this server.

pub fn update_server(&mut self, endpoint: String, token: String)[src]

Updates the voice server data.

You should only need to use this if you initialized the Call via standalone.

pub fn update_state(&mut self, session_id: String)[src]

Updates the internal voice state of the current user.

You should only need to use this if you initialized the Call via standalone.

Methods from Deref<Target = Driver>

pub fn connect(&mut self, info: ConnectionInfo) -> Connect

Notable traits for Connect

impl Future for Connect type Output = Result<()>;
[src]

Connects to a voice channel using the specified server.

This method instantly contacts the driver tasks, and its does not need to be awaited to start the actual connection.

pub fn leave(&mut self)[src]

Leaves the current voice channel, disconnecting from it.

This does not forget settings, like whether to be self-deafened or self-muted.

pub fn mute(&mut self, mute: bool)[src]

Sets whether the current connection is to be muted.

If there is no live voice connection, then this only acts as a settings update for future connections.

pub fn is_mute(&self) -> bool[src]

Returns whether the driver is muted (i.e., processes audio internally but submits none).

pub fn play_source(&mut self, source: Input) -> TrackHandle[src]

Plays audio from a source, returning a handle for further control.

This can be a source created via ffmpeg or ytdl.

pub fn play_only_source(&mut self, source: Input) -> TrackHandle[src]

Plays audio from a source, returning a handle for further control.

Unlike play_source, this stops all other sources attached to the channel.

pub fn play(&mut self, track: Track)[src]

Plays audio from a Track object.

This will be one half of the return value of create_player. The main difference between this function and play_source is that this allows for direct manipulation of the Track object before it is passed over to the voice and mixing contexts.

pub fn play_only(&mut self, track: Track)[src]

Exclusively plays audio from a Track object.

This will be one half of the return value of create_player. As in play_only_source, this stops all other sources attached to the channel. Like play, however, this allows for direct manipulation of the Track object before it is passed over to the voice and mixing contexts.

pub fn set_bitrate(&mut self, bitrate: Bitrate)[src]

Sets the bitrate for encoding Opus packets sent along the channel being managed.

The default rate is 128 kbps. Sensible values range between Bits(512) and Bits(512_000) bits per second. Alternatively, Auto and Max remain available.

pub fn stop(&mut self)[src]

Stops playing audio from all sources, if any are set.

pub fn set_config(&mut self, config: Config)[src]

Sets the configuration for this driver.

pub fn add_global_event<F: EventHandler + 'static>(
    &mut self,
    event: Event,
    action: F
)
[src]

Attach a global event handler to an audio context. Global events may receive any EventContext.

Global timing events will tick regardless of whether audio is playing, so long as the bot is connected to a voice channel, and have no tracks. TrackEvents will respond to all relevant tracks, giving some audio elements.

Users must ensure that no costly work or blocking occurs within the supplied function or closure. Taking excess time could prevent timely sending of packets, causing audio glitches and delays.

pub fn remove_all_global_events(&mut self)[src]

Removes all global event handlers from an audio context.

pub fn queue(&self) -> &TrackQueue[src]

Returns a reference to this driver’s built-in queue.

Requires the "builtin-queue" feature. Queue additions should be made via enqueue and enqueue_source.

pub fn enqueue_source(&mut self, source: Input)[src]

Adds an audio Input to this driver’s built-in queue.

Requires the "builtin-queue" feature.

pub fn enqueue(&mut self, track: Track)[src]

Adds an existing Track to this driver’s built-in queue.

Requires the "builtin-queue" feature.

Trait Implementations

impl Clone for Call[src]

impl Debug for Call[src]

impl Deref for Call[src]

type Target = Driver

The resulting type after dereferencing.

impl DerefMut for Call[src]

Auto Trait Implementations

impl !RefUnwindSafe for Call

impl Send for Call

impl Sync for Call

impl Unpin for Call

impl !UnwindSafe for Call

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<T> WithSubscriber for T[src]