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
This commit is contained in:
Clawdbot
2026-02-16 13:18:04 +01:00
committed by Peter Steinberger
parent 2fa9ddebdb
commit 952db1a3e2

View File

@@ -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,