mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 03:01:25 +00:00
fix(discord): fix component parsing and modal field typing
This commit is contained in:
@@ -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(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user