fix(discord): fix component parsing and modal field typing

This commit is contained in:
Peter Steinberger
2026-02-15 18:47:36 +00:00
parent f92900fc20
commit c118f6c688
3 changed files with 16 additions and 8 deletions

View File

@@ -34,8 +34,17 @@ export async function handleDiscordMessageAction(
if (action === "send") {
const to = readStringParam(params, "to", { required: true });
const asVoice = params.asVoice === true;
const rawComponents = params.components;
const components =
rawComponents &&
(Array.isArray(rawComponents) ||
typeof rawComponents === "function" ||
(typeof rawComponents === "object" && !Array.isArray(rawComponents)))
? rawComponents
: undefined;
const content = readStringParam(params, "message", {
required: true,
required: !asVoice && !components,
allowEmpty: true,
});
// Support media, path, and filePath for media URL
@@ -44,14 +53,8 @@ export async function handleDiscordMessageAction(
readStringParam(params, "path", { trim: false }) ??
readStringParam(params, "filePath", { trim: false });
const replyTo = readStringParam(params, "replyTo");
const rawComponents = params.components;
const components =
Array.isArray(rawComponents) || typeof rawComponents === "function"
? rawComponents
: undefined;
const rawEmbeds = params.embeds;
const embeds = Array.isArray(rawEmbeds) ? rawEmbeds : undefined;
const asVoice = params.asVoice === true;
const silent = params.silent === true;
return await handleDiscordAction(
{