From 3f1a4d113e71fc412ec05a319d5ffd5a3d7a78bc Mon Sep 17 00:00:00 2001 From: salmonik Date: Fri, 31 Jul 2026 01:09:07 +0200 Subject: fir auto completion and send file in the response body upon grajcuj file --- src/voice/mod.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/voice/mod.rs') diff --git a/src/voice/mod.rs b/src/voice/mod.rs index 0d5b89e..4087eba 100644 --- a/src/voice/mod.rs +++ b/src/voice/mod.rs @@ -25,12 +25,13 @@ pub struct VoiceManager { } impl VoiceManager { - pub async fn new(ctx: &serenity::client::Context) -> Self { - Self { - songbird: songbird::get(ctx) - .await - .expect("Songbird not registered via register_songbird()"), - } + pub async fn new(ctx: &serenity::client::Context) -> Result { + let songbird = songbird::get(ctx) + .await + .ok_or_else(|| Error::Custom( + "Songbird not registered via register_songbird()".into(), + ))?; + Ok(Self { songbird }) } pub async fn connect( @@ -54,7 +55,12 @@ impl VoiceManager { warn!("Driver error details: {driver_err:?}"); } last_err = Some(e); - tokio::time::sleep(Duration::from_secs(1)).await; + + // Stale voice state: remove the guild from songbird and + // wait a few seconds so Discord's voice gateway can fully + // process the disconnect before we retry. + let _ = self.songbird.remove(guild_id).await; + tokio::time::sleep(Duration::from_secs(3)).await; } } } -- cgit v1.2.3