mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 23:31:24 +00:00
fix(discord): support forum channel thread-create (#10062)
* fix(discord): support forum channel thread-create * fix: harden discord forum thread-create (#10062) (thanks @jarvis89757) --------- Co-authored-by: Shakker <shakkerdroid@gmail.com>
This commit is contained in:
35
src/channels/plugins/actions/discord/handle-action.test.ts
Normal file
35
src/channels/plugins/actions/discord/handle-action.test.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { handleDiscordMessageAction } from "./handle-action.js";
|
||||
|
||||
const handleDiscordAction = vi.fn(async () => ({ details: { ok: true } }));
|
||||
|
||||
vi.mock("../../../../agents/tools/discord-actions.js", () => ({
|
||||
handleDiscordAction: (...args: unknown[]) => handleDiscordAction(...args),
|
||||
}));
|
||||
|
||||
describe("handleDiscordMessageAction", () => {
|
||||
beforeEach(() => {
|
||||
handleDiscordAction.mockClear();
|
||||
});
|
||||
|
||||
it("forwards thread-create message as content", async () => {
|
||||
await handleDiscordMessageAction({
|
||||
action: "thread-create",
|
||||
params: {
|
||||
to: "channel:123456789",
|
||||
threadName: "Forum thread",
|
||||
message: "Initial forum post body",
|
||||
},
|
||||
cfg: {},
|
||||
});
|
||||
expect(handleDiscordAction).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
action: "threadCreate",
|
||||
channelId: "123456789",
|
||||
name: "Forum thread",
|
||||
content: "Initial forum post body",
|
||||
}),
|
||||
expect.any(Object),
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -184,6 +184,7 @@ export async function handleDiscordMessageAction(
|
||||
if (action === "thread-create") {
|
||||
const name = readStringParam(params, "threadName", { required: true });
|
||||
const messageId = readStringParam(params, "messageId");
|
||||
const content = readStringParam(params, "message");
|
||||
const autoArchiveMinutes = readNumberParam(params, "autoArchiveMin", {
|
||||
integer: true,
|
||||
});
|
||||
@@ -194,6 +195,7 @@ export async function handleDiscordMessageAction(
|
||||
channelId: resolveChannelId(),
|
||||
name,
|
||||
messageId,
|
||||
content,
|
||||
autoArchiveMinutes,
|
||||
},
|
||||
cfg,
|
||||
|
||||
Reference in New Issue
Block a user