From 952db1a3e2f3db4250ae3c252c4b1f0eb4f4b01b Mon Sep 17 00:00:00 2001 From: Clawdbot Date: Mon, 16 Feb 2026 13:18:04 +0100 Subject: [PATCH] fix(discord): route audioAsVoice payloads through voice message API deliverDiscordReply now checks payload.audioAsVoice and routes through sendVoiceMessageDiscord instead of sendMessageDiscord when true. This matches the existing Telegram behavior where audioAsVoice triggers the voice message path (wantsVoice: true). Fixes #17990 --- src/discord/monitor/reply-delivery.ts | 31 ++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/discord/monitor/reply-delivery.ts b/src/discord/monitor/reply-delivery.ts index f3513aad6..919bccac0 100644 --- a/src/discord/monitor/reply-delivery.ts +++ b/src/discord/monitor/reply-delivery.ts @@ -5,7 +5,7 @@ import type { MarkdownTableMode } from "../../config/types.base.js"; import type { RuntimeEnv } from "../../runtime.js"; import { convertMarkdownTables } from "../../markdown/tables.js"; import { chunkDiscordTextWithMode } from "../chunk.js"; -import { sendMessageDiscord } from "../send.js"; +import { sendMessageDiscord, sendVoiceMessageDiscord } from "../send.js"; export async function deliverDiscordReply(params: { replies: ReplyPayload[]; @@ -62,6 +62,35 @@ export async function deliverDiscordReply(params: { if (!firstMedia) { continue; } + + // Voice message path: audioAsVoice flag routes through sendVoiceMessageDiscord + if (payload.audioAsVoice) { + await sendVoiceMessageDiscord(params.target, firstMedia, { + token: params.token, + rest: params.rest, + accountId: params.accountId, + replyTo, + }); + // Voice messages cannot include text; send remaining text separately if present + if (text.trim()) { + await sendMessageDiscord(params.target, text, { + token: params.token, + rest: params.rest, + accountId: params.accountId, + }); + } + // Additional media items are sent as regular attachments (voice is single-file only) + for (const extra of mediaList.slice(1)) { + await sendMessageDiscord(params.target, "", { + token: params.token, + rest: params.rest, + mediaUrl: extra, + accountId: params.accountId, + }); + } + continue; + } + await sendMessageDiscord(params.target, text, { token: params.token, rest: params.rest,