Discord: refine voice message handling

This commit is contained in:
Shadow
2026-02-13 12:33:45 -06:00
committed by Shadow
parent 76ab377a19
commit 1c9c01ff49
5 changed files with 93 additions and 39 deletions

View File

@@ -229,21 +229,26 @@ export async function handleDiscordMessagingAction(
throw new Error("Discord message sends are disabled.");
}
const to = readStringParam(params, "to", { required: true });
const content = readStringParam(params, "content", {
required: true,
allowEmpty: true,
});
const mediaUrl = readStringParam(params, "mediaUrl");
const replyTo = readStringParam(params, "replyTo");
const asVoice = params.asVoice === true;
const silent = params.silent === true;
const content = readStringParam(params, "content", {
required: !asVoice,
allowEmpty: true,
});
const mediaUrl =
readStringParam(params, "mediaUrl", { trim: false }) ??
readStringParam(params, "path", { trim: false }) ??
readStringParam(params, "filePath", { trim: false });
const replyTo = readStringParam(params, "replyTo");
const embeds =
Array.isArray(params.embeds) && params.embeds.length > 0 ? params.embeds : undefined;
// Handle voice message sending
if (asVoice) {
if (!mediaUrl) {
throw new Error("Voice messages require a media file path (mediaUrl).");
throw new Error(
"Voice messages require a local media file path (mediaUrl, path, or filePath).",
);
}
if (content && content.trim()) {
throw new Error(
@@ -263,7 +268,7 @@ export async function handleDiscordMessagingAction(
return jsonResult({ ok: true, result, voiceMessage: true });
}
const result = await sendMessageDiscord(to, content, {
const result = await sendMessageDiscord(to, content ?? "", {
...(accountId ? { accountId } : {}),
mediaUrl,
replyTo,