From 6bc87dc64b6fd5e591903f4c4bdc408e95d5bc48 Mon Sep 17 00:00:00 2001 From: Ladislav Hano Date: Sun, 8 Dec 2024 18:08:53 +0100 Subject: [PATCH] future send error showcase --- src/commands/voice/spotify/player.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/commands/voice/spotify/player.rs b/src/commands/voice/spotify/player.rs index 37e9a16..9b3b9d5 100644 --- a/src/commands/voice/spotify/player.rs +++ b/src/commands/voice/spotify/player.rs @@ -56,6 +56,33 @@ pub async fn connect(ctx: Context<'_>, let channel: ChannelId; if name.is_none() || name.clone().unwrap() == "" { + // ERROR: <> + // !### This will work if you comment out one of the replies ###! + // let Some(guild) = ctx.guild() else { + // ctx.reply("You must be in a voice channel or specify explicit voice channel by name").await?; + // return Ok(()) + // }; + + // let Some(voice_channel) = guild.voice_states.get(&ctx.author().id).and_then(|voice_state| voice_state.channel_id) else { + // ctx.reply("You must be in a voice channel or specify explicit voice channel by name").await?; + // return Ok(()) + // }; + + // channel = voice_channel; + // !### ###! + + // This one liner works only if you comment out the reply + // channel = match ctx.guild().unwrap().voice_states.get(&ctx.author().id).and_then(|voice_state| voice_state.channel_id) { + // Some(channel) => channel, + // None => { + // // ERROR: <> + // // Will work if you comment this out + // ctx.reply("You must be in a voice channel or specify explicit voice channel by name").await?; + // return Ok(()) + // } + // } + + // This one works // Ugly one liner since I don't know how to do this another way yet // TODO fix please let Some(voice_channel) = ctx.guild().unwrap().voice_states.get(&ctx.author().id).and_then(|voice_state| voice_state.channel_id) else {