Skip to content

Commit b1ba780

Browse files
committed
fix(discord): degrade audioAsVoice to media attachment when voice adapter unavailable
When messages.tts.auto is set to "always", the TTS pipeline sets audioAsVoice=true on reply payloads. The outbound adapter then tried to route through discordVoice, falling back to sendVoiceMessageDiscord runtime. In cron delivery contexts where no voice channel connection exists, this fallback fails with "discordVoice outbound adapter is unavailable". Instead of falling back to the voice runtime (which cannot work without a voice connection), degrade gracefully: when the discordVoice dep is unavailable, fall through to the existing text+media delivery path which sends audio as a file attachment to the text channel. Closes #84952
1 parent 577e64d commit b1ba780

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

extensions/discord/src/outbound-adapter.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -230,19 +230,20 @@ export const discordOutbound: ChannelOutboundAdapter = {
230230
const formattingOptions = resolveDiscordFormattingOptions({ formatting });
231231
if (audioAsVoice && mediaUrl) {
232232
const sendVoice =
233-
resolveOutboundSendDep<DiscordVoiceSendFn>(deps, "discordVoice") ??
234-
(await loadDiscordSendRuntime()).sendVoiceMessageDiscord;
235-
return await withDiscordDeliveryRetry({
236-
cfg,
237-
accountId,
238-
fn: async () =>
239-
await sendVoice(target, mediaUrl, {
240-
cfg,
241-
replyTo: replyToId ?? undefined,
242-
accountId: accountId ?? undefined,
243-
silent: silent ?? undefined,
244-
}),
245-
});
233+
resolveOutboundSendDep<DiscordVoiceSendFn>(deps, "discordVoice");
234+
if (sendVoice) {
235+
return await withDiscordDeliveryRetry({
236+
cfg,
237+
accountId,
238+
fn: async () =>
239+
await sendVoice(target, mediaUrl, {
240+
cfg,
241+
replyTo: replyToId ?? undefined,
242+
accountId: accountId ?? undefined,
243+
silent: silent ?? undefined,
244+
}),
245+
});
246+
}
246247
}
247248
if (text.trim() && mediaUrl && isLikelyDiscordVideoMedia(mediaUrl)) {
248249
await withDiscordDeliveryRetry({

0 commit comments

Comments
 (0)