diff --git a/src/commands/play.rs b/src/commands/play.rs index 51fb51c..c947bfa 100644 --- a/src/commands/play.rs +++ b/src/commands/play.rs @@ -59,7 +59,6 @@ async fn get_tracks( if stderr.contains("YouTube said: The playlist does not exist.") { return Err("YouTube said: The playlist does not exist.".into()); } - return Err(stderr.into()); } return Err("No tracks found".into()); } diff --git a/src/commands/queue.rs b/src/commands/queue.rs index 2594708..a474c53 100644 --- a/src/commands/queue.rs +++ b/src/commands/queue.rs @@ -70,9 +70,6 @@ pub(crate) async fn build_queue_embeds(queue: &[TrackHandle], page: usize) -> Ve } pub(crate) fn build_action_row(page: usize, max_pages: usize) -> Vec { - if max_pages == 0 { - return Vec::new(); - } vec![Component::ActionRow(ActionRow { components: vec![ Component::Button(Button { @@ -85,6 +82,16 @@ pub(crate) fn build_action_row(page: usize, max_pages: usize) -> Vec url: None, disabled: page == 0, }), + Component::Button(Button { + custom_id: Some(format!("page:{}", page)), + style: ButtonStyle::Primary, + label: Some("Refresh".to_string()), + emoji: Some(ReactionType::Unicode { + name: "🔄".to_string(), + }), + url: None, + disabled: false, + }), Component::Button(Button { custom_id: Some(format!("page:{}", page + 1)), style: ButtonStyle::Primary, diff --git a/src/handler.rs b/src/handler.rs index 36f9622..dc1aa2a 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -147,8 +147,10 @@ impl Handler { let call = call_lock.lock().await; queue = call.queue().current_queue(); } + let n_pages = queue.len() / TRACKS_PER_PAGE; + let page = page.min(n_pages).max(0); let embeds = build_queue_embeds(&queue, page).await; - let action_row = build_action_row(page, queue.len() / TRACKS_PER_PAGE); + let action_row = build_action_row(page, n_pages); let interaction_response_data = InteractionResponseDataBuilder::new() .embeds(embeds)