Skip to content

fix(discord): use correct content_type property for audio attachment detection#32136

Merged
steipete merged 2 commits intoopenclaw:mainfrom
jnMetaCode:fix/discord-voice-content-type
Mar 2, 2026
Merged

fix(discord): use correct content_type property for audio attachment detection#32136
steipete merged 2 commits intoopenclaw:mainfrom
jnMetaCode:fix/discord-voice-content-type

Conversation

@jnMetaCode
Copy link
Contributor

Summary

Fixes #30034 — Discord voice messages not transcribed because the audio pipeline is never triggered.

Root cause: The preflight audio transcription code in message-handler.preflight.ts used camelCase contentType to access the MIME type on Discord attachments, but the Discord API (APIAttachment from discord-api-types/v10) uses snake_case content_type. This caused hasAudioAttachment to always evaluate to false, so voice messages in guild channels were silently dropped when mention detection was required.

Fix: Changed all 5 occurrences of contentType to content_type in the preflight detection code. The rest of the Discord codebase (e.g., message-utils.ts:241,256,383,397) already uses the correct content_type property.

Test plan

  • vitest run src/discord/monitor/message-handler.preflight — 8 tests pass
  • oxfmt --check passes
  • CI green

🤖 Generated with Claude Code

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 2, 2026

Greptile Summary

Fixed property name mismatch preventing Discord voice message transcription. Changed contentType to content_type (5 occurrences) in preflight audio detection to match Discord's APIAttachment type from discord-api-types/v10.

  • Root cause correctly identified: camelCase contentType doesn't exist on Discord API attachments, causing hasAudioAttachment to always be false
  • Fix is consistent with the rest of the Discord codebase (message-utils.ts already uses content_type)
  • All occurrences in the preflight logic properly updated
  • Tests pass according to PR description

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Score reflects a simple, focused property name correction with no logic changes. The fix correctly aligns with Discord API types and existing codebase patterns. All 5 occurrences were properly updated, and the change addresses a clear bug where audio attachments were never detected.
  • No files require special attention

Last reviewed commit: 294a3f1

@openclaw-barnacle openclaw-barnacle bot added channel: discord Channel integration: discord size: XS labels Mar 2, 2026
@steipete steipete force-pushed the fix/discord-voice-content-type branch from 294a3f1 to 342bdec Compare March 2, 2026 22:41
steipete added a commit to jnMetaCode/openclaw that referenced this pull request Mar 2, 2026
jnMetaCode and others added 2 commits March 2, 2026 22:41
…detection

The preflight audio transcription detection used camelCase `contentType`
but Discord's APIAttachment type uses snake_case `content_type`. This
caused `hasAudioAttachment` to always be false, preventing voice message
transcription from triggering in guild channels where mention detection
requires audio preflight.

Fixes openclaw#30034

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@steipete steipete force-pushed the fix/discord-voice-content-type branch from 342bdec to edf4ea8 Compare March 2, 2026 22:42
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: edf4ea84ba

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}
}

const mentionText = hasTypedText ? baseText : "";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve embed text for mention matching

Using hasTypedText ? baseText : "" for mentionText drops all mention-pattern matching whenever message.content is empty, even though baseText can legitimately contain user-visible embed text from resolveDiscordMessageText(...). In guilds with mention gating, embed-only messages (common from integrations/webhooks or relays that place text in embeds) will now be treated as unmentioned and be dropped, which is broader than the audio-placeholder fix and changes previously working behavior.

Useful? React with 👍 / 👎.

@steipete steipete merged commit 0b5d8e5 into openclaw:main Mar 2, 2026
19 of 21 checks passed
@steipete
Copy link
Contributor

steipete commented Mar 2, 2026

Landed via temp rebase onto main.

  • Gate: pnpm test src/discord/monitor/message-handler.preflight.test.ts
  • Land commit: edf4ea8
  • Merge commit: 0b5d8e5

Thanks @jnMetaCode!

dawi369 pushed a commit to dawi369/davis that referenced this pull request Mar 3, 2026
OWALabuy pushed a commit to kcinzgg/openclaw that referenced this pull request Mar 4, 2026
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Discord voice messages not transcribed (audio pipeline not triggered)

2 participants