


























@@ -12,6 +12,7 @@ vi.mock("openclaw/plugin-sdk/web-media", async () => {
1212let addRoleDiscord: typeof import("./send.js").addRoleDiscord;
1313let banMemberDiscord: typeof import("./send.js").banMemberDiscord;
1414let createThreadDiscord: typeof import("./send.js").createThreadDiscord;
15+let DiscordThreadInitialMessageError: typeof import("./send.js").DiscordThreadInitialMessageError;
1516let listGuildEmojisDiscord: typeof import("./send.js").listGuildEmojisDiscord;
1617let listThreadsDiscord: typeof import("./send.js").listThreadsDiscord;
1718let reactMessageDiscord: typeof import("./send.js").reactMessageDiscord;
@@ -60,6 +61,7 @@ beforeAll(async () => {
6061 addRoleDiscord,
6162 banMemberDiscord,
6263 createThreadDiscord,
64+ DiscordThreadInitialMessageError,
6365 listGuildEmojisDiscord,
6466 listThreadsDiscord,
6567 reactMessageDiscord,
@@ -235,6 +237,32 @@ describe("sendMessageDiscord", () => {
235237);
236238});
237239240+it("keeps created non-forum thread details when initial message send fails", async () => {
241+const { rest, getMock, postMock } = makeDiscordRest();
242+getMock.mockResolvedValue({ type: ChannelType.GuildText });
243+postMock
244+.mockResolvedValueOnce({ id: "t1", name: "thread", type: ChannelType.PublicThread })
245+.mockRejectedValueOnce(new Error("missing access"));
246+247+let thrown: unknown;
248+try {
249+await createThreadDiscord(
250+"chan1",
251+{ name: "thread", content: "Hello thread!" },
252+discordClientOpts(rest),
253+);
254+} catch (error) {
255+thrown = error;
256+}
257+258+expect(thrown).toBeInstanceOf(DiscordThreadInitialMessageError);
259+expect(thrown).toMatchObject({
260+name: "DiscordThreadInitialMessageError",
261+initialMessageError: "missing access",
262+thread: { id: "t1", name: "thread", type: ChannelType.PublicThread },
263+});
264+});
265+238266it("sends initial message for message-attached threads with content", async () => {
239267const { rest, getMock, postMock } = makeDiscordRest();
240268postMock.mockResolvedValue({ id: "t1" });
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。