From d4c934b3fd7d3d895fb1733a54506691cdcd5b2e Mon Sep 17 00:00:00 2001 From: ShaunTsai Date: Tue, 14 Apr 2026 13:41:07 +0800 Subject: [PATCH] =?UTF-8?q?fix(discord):=20react=20=F0=9F=8E=A4=20on=20voi?= =?UTF-8?q?ce=20messages=20when=20STT=20is=20disabled?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/discord.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/discord.rs b/src/discord.rs index 602e854f..749297be 100644 --- a/src/discord.rs +++ b/src/discord.rs @@ -16,7 +16,7 @@ use serenity::prelude::*; use std::collections::HashSet; use std::sync::Arc; use tokio::sync::watch; -use tracing::{debug, error, info}; +use tracing::{debug, error, info, warn}; /// Hard cap on consecutive bot messages (from any other bot) in a /// channel or thread. When this many recent messages are all from @@ -205,6 +205,7 @@ impl EventHandler for Handler { }); // Process attachments: route by content type (audio → STT, image → encode) + let mut audio_skipped = false; if !msg.attachments.is_empty() { for attachment in &msg.attachments { if is_audio_attachment(attachment) { @@ -216,7 +217,8 @@ impl EventHandler for Handler { }); } } else { - debug!(filename = %attachment.filename, "skipping audio attachment (STT disabled)"); + warn!(filename = %attachment.filename, "skipping audio attachment (STT disabled)"); + audio_skipped = true; } } else if let Some(content_block) = download_and_encode_image(attachment).await { debug!(url = %attachment.url, filename = %attachment.filename, "adding image attachment"); @@ -225,6 +227,15 @@ impl EventHandler for Handler { } } + // If audio was skipped, react with 🎤 so the user knows their voice message was noticed + if audio_skipped { + let _ = msg.react(&ctx.http, ReactionType::Unicode("🎤".into())).await; + // Voice-only message: no text and only the sender_context block → early return + if prompt.is_empty() && content_blocks.len() == 1 { + return; + } + } + tracing::debug!( text_len = prompt_with_sender.len(), num_attachments = msg.attachments.len(),