pub async fn play(
    ctx: &Context,
    guild: &Guild,
    chan_id: &ChannelId,
    author_id: &UserId,
    url: String,
) -> Result<CreateEmbed> {
    let guild_id = guild.id;
    // check if its actually a url
    if !url.starts_with("http") {
        return Err("must provide a valid URL".to_string());
    }

    let manager = _get_songbird(ctx).await;

    // get the current call lock
    if let Some(handler_lock) = manager.get(guild_id) {
        // await the lock
        let mut handler = handler_lock.lock().await;

        // Here, we use lazy restartable sources to make sure that we don't pay
        // for decoding, playback on tracks which aren't actually live yet.
        let now = std::time::Instant::now();
        let source = match Restartable::ytdl(url, true).await {
            Ok(source) => source,
            Err(why) => {
                error!("Err starting source: {:?}", why);

                return Err("error sourcing ffmgep".to_string());
            }
        };
        info!(
            "Sourcing song took {}",
            humantime::format_duration(now.elapsed())
        );

        handler.enqueue_source(source.into());
        let queue = handler.queue().current_queue();
        drop(handler);
        // save to unwrap because we just queued a track
        let track = queue.last().expect("couldn't get handle of queued track");
        let time = chrono::Utc::now();
        let _ = track.add_event(
            Event::Delayed(Duration::from_millis(20)),
            NowPlaying {
                http: ctx.http.clone(),
                chan_id: chan_id.clone(),
                author_id: author_id.clone(),
                time,
            },
        );
        let mut e = default_embed();
        e.title(format!("Added Song to position {}", queue.len()));
        return Ok(e);
    } else {
        return Err(NOT_IN_VOICE_ERROR.to_string());
    }
}
///
/// queues the given link to the song queue of the current call
///
/// also does directly play if its the first song in queue and
/// basically sends the [`now_playing`] command to inform the user
/// that the song started playing
queues the given link to the song queue of the current call
also does directly play if its the first song in queue and
basically sends the [`now_playing`] command to inform the user
that the song started playing
queues the given link to the song queue of the current call also does directly play if its the first song in queue and basically sends the [ ` now_playing ` ] command to inform the user that the song started playing
pub async fn play(
    ctx: &Context,
    guild: &Guild,
    chan_id: &ChannelId,
    author_id: &UserId,
    url: String,
) -> Result<CreateEmbed> {
    let guild_id = guild.id;
    // check if its actually a url
    if !url.starts_with("http") {
        return Err("must provide a valid URL".to_string());
    }
    let manager = _get_songbird(ctx).await;
    // get the current call lock
    if let Some(handler_lock) = manager.get(guild_id) {
        // await the lock
        let mut handler = handler_lock.lock().await;
        // Here, we use lazy restartable sources to make sure that we don't pay
        // for decoding, playback on tracks which aren't actually live yet.
        let now = std::time::Instant::now();
        let source = match Restartable::ytdl(url, true).await {
            Ok(source) => source,
            Err(why) => {
                error!("Err starting source: {:?}", why);
                return Err("error sourcing ffmgep".to_string());
            }
        };
        info!(
            "Sourcing song took {}",
            humantime::format_duration(now.elapsed())
        );
        handler.enqueue_source(source.into());
        let queue = handler.queue().current_queue();
        drop(handler);
        // save to unwrap because we just queued a track
        let track = queue.last().expect("couldn't get handle of queued track");
        let time = chrono::Utc::now();
        let _ = track.add_event(
            Event::Delayed(Duration::from_millis(20)),
            NowPlaying {
                http: ctx.http.clone(),
                chan_id: chan_id.clone(),
                author_id: author_id.clone(),
                time,
            },
        );
        let mut e = default_embed();
        e.title(format!("Added Song to position {}", queue.len()));
        return Ok(e);
    } else {
        return Err(NOT_IN_VOICE_ERROR.to_string());
    }
}
pub async fn play ( ctx : & Context , guild : & Guild , chan_id : & ChannelId , author_id : & UserId , url : String , ) -> Result < CreateEmbed > { let guild_id = guild . id ; // check if its actually a url if ! url . starts_with ( " " ) { return Err ( " " . to_string ( ) ) ; } let manager = _get_songbird ( ctx ) . await ; // get the current call lock if let Some ( handler_lock ) = manager . get ( guild_id ) { // await the lock let mut handler = handler_lock . lock ( ) . await ; // Here, we use lazy restartable sources to make sure that we don't pay // for decoding, playback on tracks which aren't actually live yet. let now = std :: time :: Instant :: now ( ) ; let source = match Restartable :: ytdl ( url , true ) . await { Ok ( source ) => source , Err ( why ) => { error ! ( " " why ) ; return Err ( " " . to_string ( ) ) ; } } ; info ! ( " " humantime format_duration ( now elapsed ( ) ) ) ; handler . enqueue_source ( source . into ( ) ) ; let queue = handler . queue ( ) . current_queue ( ) ; drop ( handler ) ; // save to unwrap because we just queued a track let track = queue . last ( ) . expect ( " " ) ; let time = chrono :: Utc :: now ( ) ; let _ = track . add_event ( Event :: Delayed ( Duration :: from_millis ( 20 ) ) , NowPlaying { http : ctx . http . clone ( ) , chan_id : chan_id . clone ( ) , author_id : author_id . clone ( ) , time , } , ) ; let mut e = default_embed ( ) ; e . title ( format ! ( " " queue len ( ) ) ) ; return Ok ( e ) ; } else { return Err ( NOT_IN_VOICE_ERROR . to_string ( ) ) ; } }
queues the given link to the song queue of the current call
also does directly play if its the first song in queue and
basically sends the [`now_playing`] command to inform the user
that the song started playing
queues the given link to the song queue of the current call also does directly play if its the first song in queue and basically sends the [ ` now_playing ` ] command to inform the user that the song started playing
ctx
&Context
guild
&Guild
chan_id
&ChannelId
author_id
&UserId
url
String
ctx
&Context
guild
&Guild
chan_id
&ChannelId
author_id
&UserId
url
String