#22940: fix(discord): detect voice messages for preflight transcription before mention check
channel: discord
size: XS
trusted-contributor
Cluster:
Signal and Discord Fixes
## Problem
Discord voice messages in `requireMention: true` channels are silently dropped before transcription runs, making it impossible for the agent to respond to voice notes that contain a mention (e.g. "Hey HAL").
Two root causes:
1. **Voice message attachments lack `contentType`** — the existing `att.contentType?.startsWith("audio/")` check returns `false` for Discord voice messages, which use the `IS_VOICE_MESSAGE` flag (bit 13 = 8192) instead of setting contentType on attachments.
2. **`baseText` contains placeholder text** — voice messages produce `"<media:document> (1 file)"` as baseText, so the `!baseText` guard fails and preflight transcription is never triggered.
## Fix
- Check `message.flags` for the `IS_VOICE_MESSAGE` bit (`1 << 13`) in addition to attachment contentType
- Treat `<media:*>` placeholder text as effectively empty for preflight transcription eligibility
- Default to `audio/ogg` MIME type for voice message attachments that lack contentType
## Changes
- `src/discord/monitor/message-handler.preflight.ts`: Voice message detection + media placeholder handling
Fixes #22878
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Fixes Discord voice message handling in `requireMention: true` channels by detecting the `IS_VOICE_MESSAGE` flag (bit 13) and treating media placeholder text as empty for preflight transcription eligibility.
**Key changes:**
- Checks `message.flags` for voice message bit (8192) in addition to `contentType`
- Treats `<media:*>` placeholder text as empty using regex pattern
- Defaults voice message attachments to `audio/ogg` when `contentType` is missing
**Issue found:**
- The `isAudioAtt` helper returns `true` for ALL attachments when `isVoiceMessage` is `true`, which could incorrectly treat non-audio attachments as audio if a voice message somehow had multiple attachments
<h3>Confidence Score: 4/5</h3>
- Safe to merge with one logical issue that should be addressed
- The fix correctly addresses the root causes described in the PR (voice message flag detection and media placeholder handling). However, there's a logical flaw in the `isAudioAtt` function that treats all attachments as audio when `isVoiceMessage` is true, which could cause issues in edge cases with multiple attachments.
- Pay close attention to src/discord/monitor/message-handler.preflight.ts:514-515 where the `isAudioAtt` logic needs refinement
<sub>Last reviewed commit: 27251d9</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#17120: fix: transcribe all Telegram voice messages, not just mention-gated...
by MisterGuy420 · 2026-02-15
81.0%
#17254: fix(discord): intercept text-based slash commands instead of forwar...
by robbyczgw-cla · 2026-02-15
78.0%
#13430: fix(discord): properly handle bot-sent @everyone mentions
by wassimbensalem · 2026-02-10
78.0%
#15914: feat: add messages.suppressMediaPlaceholders config option
by Shuai-DaiDai · 2026-02-14
77.7%
#17748: fix: transcribe voice messages in Telegram DMs (v2)
by Limitless2023 · 2026-02-16
77.4%
#20488: fix(discord): pass mediaLocalRoots to sendMessageDiscord
by olyashok · 2026-02-19
77.0%
#17513: fix(discord): respect groupPolicy in channel config fallback (#4555)
by aronchick · 2026-02-15
76.6%
#20913: fix: intercept Discord embed images to enforce mediaMaxMb
by MumuTW · 2026-02-19
76.4%
#7719: fix(slack): thread replies with @mentions dropped in requireMention...
by SocialNerd42069 · 2026-02-03
75.4%
#20186: fix(discord): thread mediaLocalRoots through reply delivery path
by pvoo · 2026-02-18
75.2%