diff --git a/src/command/join.rs b/src/command/join.rs index 2145aae..07c638d 100644 --- a/src/command/join.rs +++ b/src/command/join.rs @@ -310,41 +310,44 @@ pub async fn handle(state: State, interaction: Interaction) { call.mute(true).await.expect("TODO"); } - state - .songbird - .join(guild_id, voice_channel_id) - .await - .expect("TODO"); - tracing::error!(?call, "successfully joined"); + match state.songbird.join(guild_id, voice_channel_id).await { + Ok(_call) => { + tracing::error!(?call, "successfully joined"); - let channel_mention = format!("<#{voice_channel_id}>"); + let channel_mention = format!("<#{voice_channel_id}>"); - let info_mention = format!( - "", - state.discord_info_command_name, state.discord_info_command_id - ); - let opt_in_mention = format!( - "", - state.discord_opt_in_command_name, state.discord_opt_in_command_id - ); - let opt_out_mention = format!( - "", - state.discord_opt_out_command_name, state.discord_opt_out_command_id - ); + let info_mention = format!( + "", + state.discord_info_command_name, state.discord_info_command_id + ); + let opt_in_mention = format!( + "", + state.discord_opt_in_command_name, state.discord_opt_in_command_id + ); + let opt_out_mention = format!( + "", + state.discord_opt_out_command_name, state.discord_opt_out_command_id + ); - state - .discord_client - .interaction(state.discord_application_id) - .update_response( - &interaction.token, - ).embeds(Some(&[ - EmbedBuilder::new() - .title("Joined VC to record") - .description(format!("This bot joined {channel_mention} and intends to record. You can opt out with {opt_out_mention} or explicitly opt in with {opt_in_mention} (I'd appreciate this one). Please use {info_mention} for more information about this bot.")) - .validate() - .unwrap() - .build() - ])) - .await - .expect("TODO"); + state + .discord_client + .interaction(state.discord_application_id) + .update_response( + &interaction.token, + ).embeds(Some(&[ + EmbedBuilder::new() + .title("Joined VC to record") + .description(format!("This bot joined {channel_mention} and intends to record. You can opt out with {opt_out_mention} or explicitly opt in with {opt_in_mention} (I'd appreciate this one). Please use {info_mention} for more information about this bot.")) + .validate() + .unwrap() + .build() + ])) + .await + .expect("TODO"); + }, + Err(join_error) => { + tracing::error!(?join_error); + let _ = state.songbird.remove(guild_id).await; + } + } }