future send error showcase

This commit is contained in:
Ladislav Hano 2024-12-08 18:08:53 +01:00
parent c6fa8aea9d
commit 6bc87dc64b

View file

@ -56,6 +56,33 @@ pub async fn connect(ctx: Context<'_>,
let channel: ChannelId; let channel: ChannelId;
if name.is_none() || name.clone().unwrap() == "" { 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 // Ugly one liner since I don't know how to do this another way yet
// TODO fix please // 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 { let Some(voice_channel) = ctx.guild().unwrap().voice_states.get(&ctx.author().id).and_then(|voice_state| voice_state.channel_id) else {