Skip to content

Commit f28f704

Browse files
authored
Merge pull request #252 from shaun-agent/fix/voice-msg-feedback-when-stt-disabled
fix(discord): react 🎤 on voice messages when STT is disabled
2 parents 9ce771b + d4c934b commit f28f704

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)