From 0e53ea809f8fade87609afd2480f5736c40bb1c4 Mon Sep 17 00:00:00 2001 From: tkt <37575408+tktcorporation@users.noreply.github.com> Date: Thu, 16 May 2024 16:54:25 +0000 Subject: [PATCH] :sparkles: feedback a bot conflict message --- src/commands/usecase/services/error.rs | 2 ++ src/commands/usecase/services/join/service.rs | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/commands/usecase/services/error.rs b/src/commands/usecase/services/error.rs index 93a15bf..59f1e1d 100644 --- a/src/commands/usecase/services/error.rs +++ b/src/commands/usecase/services/error.rs @@ -10,6 +10,7 @@ use std::fmt; pub enum Error { NotInVoiceChannel, ErrorSourcingFfmpeg, + AlreadyJoined, JoinError(JoinError), SerenityError(SerenityError), TrackError(TrackError), @@ -20,6 +21,7 @@ impl fmt::Display for Error { match self { Error::NotInVoiceChannel => f.write_str("Not in a voice channel."), Error::ErrorSourcingFfmpeg => f.write_str("Error sourcing ffmpeg."), + Error::AlreadyJoined => f.write_str("Already joined. I'm busy!"), Error::JoinError(e) => e.fmt(f), Error::SerenityError(e) => e.fmt(f), Error::TrackError(e) => e.fmt(f), diff --git a/src/commands/usecase/services/join/service.rs b/src/commands/usecase/services/join/service.rs index d55596c..b8879b9 100644 --- a/src/commands/usecase/services/join/service.rs +++ b/src/commands/usecase/services/join/service.rs @@ -23,6 +23,11 @@ pub async fn join( .await .expect("Songbird Voice client placed in at initialisation."); + let has_handler = manager.get(guild.id).is_some(); + if has_handler { + return Err(Error::AlreadyJoined); + } + // voice settings let client = config::client::new(crate::infrastructure::GuildPath::new(&guild.id)); client.write(config::Config { speech_options }); @@ -75,6 +80,7 @@ async fn _clear(handle_lock: &std::sync::Arc songbird::input::Input { let file_path = SharedSoundPath::new().welcome_audio_path(); + print!("file_path: {:?}", file_path); ffmpeg(file_path) .await .expect("This might fail: handle this error!")