pub async fn join(ctx: &Context, guild: &Guild, author_id: UserId) -> Result<CreateEmbed> {
    // get guild id the message was send in
    let guild_id = guild.id;

    // find the voice channel of the author
    // None when author is in no channel
    let channel_id = guild
        .voice_states
        .get(&author_id)
        .and_then(|voice_state| voice_state.channel_id);

    // check if author is in any channel
    let connect_to = match channel_id {
        Some(channel) => channel,
        None => {
            return Err(NOT_IN_VOICE_ERROR.to_string());
        }
    };

    let manager = _get_songbird(ctx).await;
    let (handle_lock, success) = manager.join(guild_id, connect_to).await;

    if let Ok(_channel) = success {
        let mut handle = handle_lock.lock().await;
        let bitrate = match handle.current_channel() {
            Some(channel) => _get_bitrate_for_channel(channel, &ctx.http).await,
            None => DEFAULT_BITRATE,
        };

        handle.set_bitrate(Bitrate::BitsPerSecond(bitrate.clone()));
        drop(handle);
        info!("setting bitrate {} for guild {}", bitrate, guild_id);
    } else {
        return Err("couldn't join the channel".to_string());
    }
    let mut e = default_embed();
    e.description(&format!("Joined {}", connect_to.mention()));
    Ok(e)
}
///
/// joins the the current channel of the message author
///
joins the the current channel of the message author
joins the the current channel of the message author
pub async fn join(ctx: &Context, guild: &Guild, author_id: UserId) -> Result<CreateEmbed> {
    // get guild id the message was send in
    let guild_id = guild.id;
    // find the voice channel of the author
    // None when author is in no channel
    let channel_id = guild
        .voice_states
        .get(&author_id)
        .and_then(|voice_state| voice_state.channel_id);
    // check if author is in any channel
    let connect_to = match channel_id {
        Some(channel) => channel,
        None => {
            return Err(NOT_IN_VOICE_ERROR.to_string());
        }
    };
    let manager = _get_songbird(ctx).await;
    let (handle_lock, success) = manager.join(guild_id, connect_to).await;
    if let Ok(_channel) = success {
        let mut handle = handle_lock.lock().await;
        let bitrate = match handle.current_channel() {
            Some(channel) => _get_bitrate_for_channel(channel, &ctx.http).await,
            None => DEFAULT_BITRATE,
        };
        handle.set_bitrate(Bitrate::BitsPerSecond(bitrate.clone()));
        drop(handle);
        info!("setting bitrate {} for guild {}", bitrate, guild_id);
    } else {
        return Err("couldn't join the channel".to_string());
    }
    let mut e = default_embed();
    e.description(&format!("Joined {}", connect_to.mention()));
    Ok(e)
}
pub async fn join ( ctx : & Context , guild : & Guild , author_id : UserId ) -> Result < CreateEmbed > { // get guild id the message was send in let guild_id = guild . id ; // find the voice channel of the author // None when author is in no channel let channel_id = guild . voice_states . get ( & author_id ) . and_then ( | voice_state | voice_state . channel_id ) ; // check if author is in any channel let connect_to = match channel_id { Some ( channel ) => channel , None => { return Err ( NOT_IN_VOICE_ERROR . to_string ( ) ) ; } } ; let manager = _get_songbird ( ctx ) . await ; let ( handle_lock , success ) = manager . join ( guild_id , connect_to ) . await ; if let Ok ( _channel ) = success { let mut handle = handle_lock . lock ( ) . await ; let bitrate = match handle . current_channel ( ) { Some ( channel ) => _get_bitrate_for_channel ( channel , & ctx . http ) . await , None => DEFAULT_BITRATE , } ; handle . set_bitrate ( Bitrate :: BitsPerSecond ( bitrate . clone ( ) ) ) ; drop ( handle ) ; info ! ( " " bitrate guild_id ) ; } else { return Err ( " " . to_string ( ) ) ; } let mut e = default_embed ( ) ; e . description ( & format ! ( " " connect_to mention ( ) ) ) ; Ok ( e ) }
joins the the current channel of the message author
joins the the current channel of the message author
ctx
&Context
guild
&Guild
author_id
UserId
ctx
&Context
guild
&Guild
author_id
UserId