Discord: honor explicit thread type
This commit is contained in:
parent
9e92fc8fa1
commit
e95f41b5df
@ -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 () => {
|
it("lists active threads by guild", async () => {
|
||||||
const { rest, getMock } = makeRest();
|
const { rest, getMock } = makeRest();
|
||||||
getMock.mockResolvedValue({ threads: [] });
|
getMock.mockResolvedValue({ threads: [] });
|
||||||
|
|||||||
@ -105,6 +105,9 @@ export async function createThreadDiscord(
|
|||||||
if (payload.autoArchiveMinutes) {
|
if (payload.autoArchiveMinutes) {
|
||||||
body.auto_archive_duration = payload.autoArchiveMinutes;
|
body.auto_archive_duration = payload.autoArchiveMinutes;
|
||||||
}
|
}
|
||||||
|
if (!payload.messageId && payload.type !== undefined) {
|
||||||
|
body.type = payload.type;
|
||||||
|
}
|
||||||
let channelType: ChannelType | undefined;
|
let channelType: ChannelType | undefined;
|
||||||
if (!payload.messageId) {
|
if (!payload.messageId) {
|
||||||
// Only detect channel kind for route-less thread creation.
|
// Only detect channel kind for route-less thread creation.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user