Discord: honor explicit thread type

This commit is contained in:
Shadow
2026-02-11 11:04:30 -06:00
committed by Shadow
parent 9e92fc8fa1
commit e95f41b5df
2 changed files with 21 additions and 0 deletions

View File

@@ -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: [] });

View File

@@ -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.