From fc32017a10bf1b303e056c1ef8513bebe4852a69 Mon Sep 17 00:00:00 2001 From: Miguel da Mota Date: Sun, 10 Mar 2024 16:19:19 +0100 Subject: [PATCH] fix: mutex lock --- src/main.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 926461d..55eeaf4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -38,7 +38,9 @@ lazy_static! { } pub async fn get_queue(guild_id: &GuildId) -> MusicQueue { - match HASHMAP.lock().await.get(&guild_id) { + let mut queues = HASHMAP.lock().await; + + match queues.get(&guild_id) { Some(music_queue) => music_queue.clone(), None => { let q = MusicQueue { @@ -46,7 +48,7 @@ pub async fn get_queue(guild_id: &GuildId) -> MusicQueue { queue: Vec::new(), now_playing: None, }; - HASHMAP.lock().await.insert(*guild_id, q.clone()); + queues.insert(*guild_id, q.clone()); q } }