mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 16:44:33 +00:00
Discord: CV2! (#16364)
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user