chore: rename music_queue::get_head
to next
This commit is contained in:
parent
eecb61b9f5
commit
59bf59295e
3 changed files with 6 additions and 6 deletions
|
@ -37,7 +37,7 @@ impl EventHandler for TrackEndNotifier {
|
||||||
}
|
}
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let mut head = match music_queue::get_head(&self.guild_id).await {
|
let mut head = match music_queue::next(&self.guild_id).await {
|
||||||
Some(head) => head,
|
Some(head) => head,
|
||||||
None => {
|
None => {
|
||||||
println!("Cannot get head of queue");
|
println!("Cannot get head of queue");
|
||||||
|
|
|
@ -84,7 +84,7 @@ pub async fn attempt_to_queue_song(
|
||||||
return Embed::create_yt_playing(src, username, "Added to queue").await;
|
return Embed::create_yt_playing(src, username, "Added to queue").await;
|
||||||
}
|
}
|
||||||
|
|
||||||
let _query = music_queue::get_head(guild_id)
|
let _query = music_queue::next(guild_id)
|
||||||
.await
|
.await
|
||||||
.expect("Cannot get head of queue");
|
.expect("Cannot get head of queue");
|
||||||
music_queue::set_now_playing(guild_id, Some(src.clone())).await;
|
music_queue::set_now_playing(guild_id, Some(src.clone())).await;
|
||||||
|
@ -103,6 +103,7 @@ pub async fn attempt_to_queue_song(
|
||||||
// Start playing
|
// Start playing
|
||||||
let mut handler = handler_lock.lock().await;
|
let mut handler = handler_lock.lock().await;
|
||||||
let _ = handler.play_input(src.clone().into()); // TODO: Add event handlers
|
let _ = handler.play_input(src.clone().into()); // TODO: Add event handlers
|
||||||
|
|
||||||
handler.add_global_event(
|
handler.add_global_event(
|
||||||
Event::Track(TrackEvent::End),
|
Event::Track(TrackEvent::End),
|
||||||
music_events::TrackEndNotifier {
|
music_events::TrackEndNotifier {
|
||||||
|
@ -190,7 +191,7 @@ pub async fn attempt_to_skip_current_song(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let head = music_queue::get_head(guild_id).await; // TODO match
|
let head = music_queue::next(guild_id).await; // TODO match
|
||||||
if head.is_none() {
|
if head.is_none() {
|
||||||
return Embed::create_error_respose(
|
return Embed::create_error_respose(
|
||||||
username,
|
username,
|
||||||
|
|
|
@ -10,7 +10,6 @@ type MusicQueueItem = Arc<Mutex<MusicQueue>>;
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct MusicQueue {
|
pub struct MusicQueue {
|
||||||
// God this sucks. This needs to be reprogrammed properly.
|
// God this sucks. This needs to be reprogrammed properly.
|
||||||
pub guild_id: GuildId,
|
|
||||||
pub queue: VecDeque<YoutubeDl>,
|
pub queue: VecDeque<YoutubeDl>,
|
||||||
pub now_playing: Option<YoutubeDl>,
|
pub now_playing: Option<YoutubeDl>,
|
||||||
}
|
}
|
||||||
|
@ -25,7 +24,6 @@ async fn get_music_queue(guild_id: &GuildId) -> MusicQueueItem {
|
||||||
queues
|
queues
|
||||||
.entry(*guild_id)
|
.entry(*guild_id)
|
||||||
.or_insert(Arc::new(Mutex::new(MusicQueue {
|
.or_insert(Arc::new(Mutex::new(MusicQueue {
|
||||||
guild_id: *guild_id,
|
|
||||||
queue: VecDeque::new(),
|
queue: VecDeque::new(),
|
||||||
now_playing: None,
|
now_playing: None,
|
||||||
})))
|
})))
|
||||||
|
@ -55,7 +53,8 @@ pub async fn add_to_queue(guild_id: &GuildId, input: YoutubeDl) {
|
||||||
with_music_queue(guild_id, |queue| queue.queue.push_back(input)).await;
|
with_music_queue(guild_id, |queue| queue.queue.push_back(input)).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_head(guild_id: &GuildId) -> Option<YoutubeDl> {
|
/// Get next track in queue
|
||||||
|
pub async fn next(guild_id: &GuildId) -> Option<YoutubeDl> {
|
||||||
with_music_queue(guild_id, |queue| queue.queue.pop_front()).await
|
with_music_queue(guild_id, |queue| queue.queue.pop_front()).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue