mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
Discord: honor explicit thread type
This commit is contained in:
@@ -120,6 +120,24 @@ describe("sendMessageDiscord", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("respects explicit thread type for standalone threads", async () => {
|
||||
const { rest, getMock, postMock } = makeRest();
|
||||
getMock.mockResolvedValue({ type: ChannelType.GuildText });
|
||||
postMock.mockResolvedValue({ id: "t1" });
|
||||
await createThreadDiscord(
|
||||
"chan1",
|
||||
{ name: "thread", type: ChannelType.PrivateThread },
|
||||
{ rest, token: "t" },
|
||||
);
|
||||
expect(getMock).toHaveBeenCalledWith(Routes.channel("chan1"));
|
||||
expect(postMock).toHaveBeenCalledWith(
|
||||
Routes.threads("chan1"),
|
||||
expect.objectContaining({
|
||||
body: expect.objectContaining({ name: "thread", type: ChannelType.PrivateThread }),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("lists active threads by guild", async () => {
|
||||
const { rest, getMock } = makeRest();
|
||||
getMock.mockResolvedValue({ threads: [] });
|
||||
|
||||
@@ -105,6 +105,9 @@ export async function createThreadDiscord(
|
||||
if (payload.autoArchiveMinutes) {
|
||||
body.auto_archive_duration = payload.autoArchiveMinutes;
|
||||
}
|
||||
if (!payload.messageId && payload.type !== undefined) {
|
||||
body.type = payload.type;
|
||||
}
|
||||
let channelType: ChannelType | undefined;
|
||||
if (!payload.messageId) {
|
||||
// Only detect channel kind for route-less thread creation.
|
||||
|
||||
Reference in New Issue
Block a user