Bladeren bron

rewording some error messages, general cleaning up

Zhizhou Ma 3 jaren geleden
bovenliggende
commit
e08d063324
3 gewijzigde bestanden met toevoegingen van 6 en 18 verwijderingen
  1. 4 8
      src/audio/audio.rs
  2. 2 7
      src/audio/loader.rs
  3. 0 3
      src/audio/song.rs

+ 4 - 8
src/audio/audio.rs

@@ -2,19 +2,15 @@ use std::{
     sync::Arc,
     collections::HashMap,
 };
-use rspotify::model::idtypes::Track;
 use serenity::{
     client::Context, 
     framework::standard::{
         Args, CommandResult,
         macros::{command, group},
     },
-    http::Http, model::{channel::Message, id::{ChannelId, GuildId}}
-};
-use songbird::tracks::{
-    TrackHandle,
-    TrackCommand,
+    model::{channel::Message, id::GuildId}
 };
+use songbird::tracks::TrackCommand;
 use tokio::{
     sync::Mutex,
 };
@@ -30,7 +26,7 @@ use crate::util::{
 };
 
 #[group]
-#[commands(join,play,skip,pause,resume,shuffle,clear,splay,queue)]
+#[commands(join,disconnect,play,skip,pause,resume,shuffle,clear,splay,queue)]
 struct Audio;
 
 lazy_static! {
@@ -63,7 +59,7 @@ async fn get_audio_state(ctx: &Context, msg: &Message) -> Option<Arc<AudioState>
             };
             let manager = songbird::get(ctx)
                 .await
-                .expect("Err get_audio_state: Songbird not initialized")
+                .unwrap()
                 .clone();
             let (handle_lock, success) = manager.join(guild_id, channel_id).await;
             if let Err(err) = success{

+ 2 - 7
src/audio/loader.rs

@@ -12,14 +12,9 @@ pub struct Loader {
 }
 
 impl Loader{
-    pub async fn kill(& self){
-        if let Err(err) = self.kill.send(()).await{
-            println!("Error in Loader.kill: {}", err.to_string());
-        };
-    }
     pub async fn add_work(& self, work: Work){
         if let Err(err) = self.work.send(work).await{
-            println!("Error in Loader.kill: {}", err.to_string());
+            println!("Error in Loader::add_work: {}", err.to_string());
         };
     }
     async fn loader_loop(mut work: mpsc::Receiver<Work>,){
@@ -33,7 +28,7 @@ impl Loader{
             let url = ytdl(&work.query).await;
     
             if let Err(err) = work.sender.send(url).await{
-                println!("Error in loader_loop: {:?}", err);
+                println!("Error in Loader::loader_loop: {:?}", err);
             };
 
             {

+ 0 - 3
src/audio/song.rs

@@ -55,9 +55,6 @@ impl Song{
         };
         Some((song, Some(work)))
     }
-    pub fn get_metadata(&self) -> &SongMetadata {
-        return &self.metadata;
-    }
     pub async fn get_url(&mut self) -> String{
         match &mut self.url_state{
             SongUrlState::Proc{receiver,..} => {