Skip to content

Commit d4c934b

Browse files
committed
fix(discord): react 🎀 on voice messages when STT is disabled
When STT is not configured, voice messages were silently dropped β€” no reaction, no reply. Users thought the bot was broken. Changes: - Track audio_skipped flag during attachment processing - Upgrade debug!() β†’ warn!() for operator log visibility - React with 🎀 emoji so users know their voice message was noticed - Early return for voice-only messages to avoid sending empty prompts to the downstream agent For mixed messages (text + voice), the text is still processed normally and the 🎀 reaction signals that the audio portion was ignored.
1 parent 9ce771b commit d4c934b

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

β€Žsrc/discord.rsβ€Ž

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use serenity::prelude::*;
1616
use std::collections::HashSet;
1717
use std::sync::Arc;
1818
use tokio::sync::watch;
19-
use tracing::{debug, error, info};
19+
use tracing::{debug, error, info, warn};
2020

2121
/// Hard cap on consecutive bot messages (from any other bot) in a
2222
/// channel or thread. When this many recent messages are all from
@@ -205,6 +205,7 @@ impl EventHandler for Handler {
205205
});
206206

207207
// Process attachments: route by content type (audio β†’ STT, image β†’ encode)
208+
let mut audio_skipped = false;
208209
if !msg.attachments.is_empty() {
209210
for attachment in &msg.attachments {
210211
if is_audio_attachment(attachment) {
@@ -216,7 +217,8 @@ impl EventHandler for Handler {
216217
});
217218
}
218219
} else {
219-
debug!(filename = %attachment.filename, "skipping audio attachment (STT disabled)");
220+
warn!(filename = %attachment.filename, "skipping audio attachment (STT disabled)");
221+
audio_skipped = true;
220222
}
221223
} else if let Some(content_block) = download_and_encode_image(attachment).await {
222224
debug!(url = %attachment.url, filename = %attachment.filename, "adding image attachment");
@@ -225,6 +227,15 @@ impl EventHandler for Handler {
225227
}
226228
}
227229

230+
// If audio was skipped, react with 🎀 so the user knows their voice message was noticed
231+
if audio_skipped {
232+
let _ = msg.react(&ctx.http, ReactionType::Unicode("🎀".into())).await;
233+
// Voice-only message: no text and only the sender_context block β†’ early return
234+
if prompt.is_empty() && content_blocks.len() == 1 {
235+
return;
236+
}
237+
}
238+
228239
tracing::debug!(
229240
text_len = prompt_with_sender.len(),
230241
num_attachments = msg.attachments.len(),

0 commit comments

Comments
Β (0)