fix: remove handlers after failing to join call

This commit is contained in:
2026-05-14 00:54:34 -04:00
parent c20bab2761
commit b2af146360

View File

@@ -310,41 +310,44 @@ pub async fn handle(state: State, interaction: Interaction) {
call.mute(true).await.expect("TODO"); call.mute(true).await.expect("TODO");
} }
state match state.songbird.join(guild_id, voice_channel_id).await {
.songbird Ok(_call) => {
.join(guild_id, voice_channel_id) tracing::error!(?call, "successfully joined");
.await
.expect("TODO");
tracing::error!(?call, "successfully joined");
let channel_mention = format!("<#{voice_channel_id}>"); let channel_mention = format!("<#{voice_channel_id}>");
let info_mention = format!( let info_mention = format!(
"</{}:{}>", "</{}:{}>",
state.discord_info_command_name, state.discord_info_command_id state.discord_info_command_name, state.discord_info_command_id
); );
let opt_in_mention = format!( let opt_in_mention = format!(
"</{}:{}>", "</{}:{}>",
state.discord_opt_in_command_name, state.discord_opt_in_command_id state.discord_opt_in_command_name, state.discord_opt_in_command_id
); );
let opt_out_mention = format!( let opt_out_mention = format!(
"</{}:{}>", "</{}:{}>",
state.discord_opt_out_command_name, state.discord_opt_out_command_id state.discord_opt_out_command_name, state.discord_opt_out_command_id
); );
state state
.discord_client .discord_client
.interaction(state.discord_application_id) .interaction(state.discord_application_id)
.update_response( .update_response(
&interaction.token, &interaction.token,
).embeds(Some(&[ ).embeds(Some(&[
EmbedBuilder::new() EmbedBuilder::new()
.title("Joined VC to record") .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.")) .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() .validate()
.unwrap() .unwrap()
.build() .build()
])) ]))
.await .await
.expect("TODO"); .expect("TODO");
},
Err(join_error) => {
tracing::error!(?join_error);
let _ = state.songbird.remove(guild_id).await;
}
}
} }