← Back to PRs

#22940: fix(discord): detect voice messages for preflight transcription before mention check

by aldoeliacim open 2026-02-21 21:05 View on GitHub →
channel: discord size: XS trusted-contributor
## 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