Explorar el Código

Remove shuffle and loop commands

Frans Bergman hace 3 años
padre
commit
dadb2e80e7
Se han modificado 3 ficheros con 1 adiciones y 63 borrados
  1. 1 45
      src/audio/audio.rs
  2. 0 8
      src/audio/audio_state.rs
  3. 0 10
      src/audio/song_queue.rs

+ 1 - 45
src/audio/audio.rs

@@ -15,18 +15,7 @@ use tokio::sync::Mutex;
 use crate::util::{message_react, send_embed};
 
 #[group]
-#[commands(
-    join,
-    disconnect,
-    play,
-    skip,
-    pause,
-    resume,
-    change_loop,
-    shuffle,
-    clear,
-    queue
-)]
+#[commands(join, disconnect, play, skip, pause, resume, clear, queue)]
 struct Audio;
 
 lazy_static! {
@@ -209,22 +198,6 @@ async fn resume(ctx: &Context, msg: &Message) -> CommandResult {
     Ok(())
 }
 
-#[command]
-async fn shuffle(ctx: &Context, msg: &Message) -> CommandResult {
-    let audio_state = get_audio_state(ctx, msg).await;
-    let audio_state = match audio_state {
-        Some(audio_state) => audio_state,
-        None => return Ok(()),
-    };
-
-    if let Err(why) = AudioState::shuffle(audio_state).await {
-        send_embed(ctx, msg, &format!("Error: {}", why)).await;
-    } else {
-        message_react(ctx, msg, "🔀").await;
-    };
-    Ok(())
-}
-
 #[command]
 async fn clear(ctx: &Context, msg: &Message) -> CommandResult {
     let audio_state = get_audio_state(ctx, msg).await;
@@ -242,23 +215,6 @@ async fn clear(ctx: &Context, msg: &Message) -> CommandResult {
     Ok(())
 }
 
-#[command]
-#[aliases("loop")]
-async fn change_loop(ctx: &Context, msg: &Message) -> CommandResult {
-    let audio_state = get_audio_state(ctx, msg).await;
-    let audio_state = match audio_state {
-        Some(audio_state) => audio_state,
-        None => return Ok(()),
-    };
-
-    match AudioState::change_looping(audio_state).await {
-        Ok(true) => message_react(ctx, msg, "🔄").await,
-        Ok(false) => message_react(ctx, msg, "➡").await,
-        Err(why) => send_embed(ctx, msg, &format!("Error: {}", why)).await,
-    };
-    Ok(())
-}
-
 #[command]
 async fn queue(ctx: &Context, msg: &Message) -> CommandResult {
     let audio_state = get_audio_state(ctx, msg).await;

+ 0 - 8
src/audio/audio_state.rs

@@ -160,14 +160,6 @@ impl AudioState {
         }
     }
 
-    pub async fn shuffle(audio_state: Arc<AudioState>) -> Result<(), String> {
-        audio_state.queue.shuffle().await
-    }
-
-    pub async fn clear(audio_state: Arc<AudioState>) -> Result<(), String> {
-        audio_state.queue.clear().await
-    }
-
     // on success, returns a bool that specifies whether the queue is now being looped
     pub async fn change_looping(audio_state: Arc<AudioState>) -> Result<bool, String> {
         {

+ 0 - 10
src/audio/song_queue.rs

@@ -1,5 +1,4 @@
 use super::song::Song;
-use rand::seq::SliceRandom;
 use std::{cmp::min, collections::VecDeque, sync::Arc};
 use tokio::sync::Mutex;
 pub struct SongQueue {
@@ -22,15 +21,6 @@ impl SongQueue {
         let mut queue = self.queue.lock().await;
         queue.pop_front()
     }
-    pub async fn shuffle(&self) -> Result<(), String> {
-        let mut queue = self.queue.lock().await;
-        if queue.len() == 0 {
-            return Err("queue is empty".to_string());
-        }
-        queue.make_contiguous().shuffle(&mut rand::thread_rng());
-
-        Ok(())
-    }
     pub async fn clear(&self) -> Result<(), String> {
         let mut queue = self.queue.lock().await;
         if queue.len() == 0 {