diff options
Diffstat (limited to 'src/commands/meme/mod.rs')
| -rw-r--r-- | src/commands/meme/mod.rs | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/commands/meme/mod.rs b/src/commands/meme/mod.rs index 7bc8b2e..eb6aa1d 100644 --- a/src/commands/meme/mod.rs +++ b/src/commands/meme/mod.rs @@ -19,6 +19,10 @@ use songbird::input::{ Compose, Input, }; +use std::{ + borrow::ToOwned, + default::Default, +}; pub use self::{ create::*, @@ -102,14 +106,23 @@ async fn send_meme( if let Some(audio) = audio { let audio = audio?; - let (_sb, call) = songbird(ctx).await?; - let mut call = call.lock().await; + let Some(voice_channel) = util::best_voice_channel(ctx) else { + tracing::error!(?ctx, "couldn't find a relevant voice channel"); + util::react(ctx, '🔇').await?; - if call.current_channel().is_none() { - call.join(CONFIG.discord.voice_channel()).await?; - } + return Ok(()); + }; + + { + let (_sb, call) = songbird(ctx).await?; + let mut call = call.lock().await; - call.enqueue_input(Input::Lazy(Box::new(audio))).await; + if call.current_channel().is_none() { + call.join(voice_channel).await?; + } + + call.enqueue_input(Input::Lazy(Box::new(audio))).await; + } util::react(ctx, ReactionType::Unicode("📣".to_owned())).await?; } |
