Discord: CV2! (#16364)

This commit is contained in:
Shadow
2026-02-15 10:24:53 -06:00
committed by GitHub
parent 95355ba25a
commit 9203a2fdb1
22 changed files with 753 additions and 225 deletions

View File

@@ -67,6 +67,31 @@ describe("handleDiscordMessageAction", () => {
);
});
it("forwards legacy embeds for send", async () => {
sendMessageDiscord.mockClear();
const handleDiscordMessageAction = await loadHandleDiscordMessageAction();
const embeds = [{ title: "Legacy", description: "Use components v2." }];
await handleDiscordMessageAction({
action: "send",
params: {
to: "channel:123",
message: "hi",
embeds,
},
cfg: {} as OpenClawConfig,
});
expect(sendMessageDiscord).toHaveBeenCalledWith(
"channel:123",
"hi",
expect.objectContaining({
embeds,
}),
);
});
it("falls back to params accountId when context missing", async () => {
sendPollDiscord.mockClear();

View File

@@ -44,7 +44,13 @@ export async function handleDiscordMessageAction(
readStringParam(params, "path", { trim: false }) ??
readStringParam(params, "filePath", { trim: false });
const replyTo = readStringParam(params, "replyTo");
const embeds = Array.isArray(params.embeds) ? params.embeds : undefined;
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(
@@ -55,6 +61,7 @@ export async function handleDiscordMessageAction(
content,
mediaUrl: mediaUrl ?? undefined,
replyTo: replyTo ?? undefined,
components,
embeds,
asVoice,
silent,