mod: mute audience feature

This commit is contained in:
2026-08-02 13:45:17 -04:00
parent 451275682d
commit bca88c7a70
6 changed files with 193 additions and 20 deletions
+28 -10
View File
@@ -4,6 +4,7 @@ use serenity::all::{
};
use super::controls::{self, ControlAction};
use super::voice;
use crate::app::buzzer::{
BUZZER_CUSTOM_ID, BuzzerSessionKey, LOCK_CUSTOM_ID, RESET_CUSTOM_ID, UNLOCK_CUSTOM_ID,
buzzer_sound, session_components,
@@ -87,18 +88,35 @@ async fn press(ctx: &Context, interaction: &ComponentInteraction) {
}
let guild_id = active_session.guild_id;
drop(session);
match songbird::get(ctx).await {
Some(manager) => match manager.get(guild_id) {
Some(call) => {
call.lock().await.play_only_input(buzzer_sound());
}
None => {
tracing::error!(%guild_id, "bot is not connected to voice for active buzzer");
}
},
None => tracing::error!("voice manager unavailable while playing buzzer"),
}
let Some(manager) = songbird::get(ctx).await else {
tracing::error!("voice manager unavailable while playing buzzer");
return;
};
let Some(call) = manager.get(guild_id) else {
tracing::error!(%guild_id, "bot is not connected to voice for active buzzer");
return;
};
let exempt_user_ids = [active_session.host_id, interaction.user.id];
let voice_result = voice::mute_channel_except(ctx, active_session, &exempt_user_ids).await;
if voice_result.failures > 0 {
tracing::warn!(
failures = voice_result.failures,
%guild_id,
"buzzer locked with participant mute failures"
);
call.lock().await.play_only_input(buzzer_sound());
let warning = EditInteractionResponse::new().content(format!(
"<@{}> buzzed first! I couldn't mute {} participant(s); check my Mute Members permission and role position.",
interaction.user.id, voice_result.failures,
));
if let Err(error) = interaction.edit_response(&ctx.http, warning).await {
tracing::error!(?error, "failed to report participant mute failures");
}
}
}
async fn run_control(ctx: &Context, interaction: &ComponentInteraction, action: ControlAction) {