mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-19 18:39:20 -05:00
fix: honor explicit discord thread type (#14162) (thanks @0xRaini)
This commit is contained in:
@@ -14,6 +14,7 @@ Docs: https://docs.openclaw.ai
|
||||
|
||||
- Ollama: use configured `models.providers.ollama.baseUrl` for model discovery and normalize `/v1` endpoints to the native Ollama API root. (#14131) Thanks @shtse8.
|
||||
- Slack: detect control commands when channel messages start with bot mention prefixes (for example, `@Bot /new`). (#14142) Thanks @beefiker.
|
||||
- Discord: default standalone threads to public while honoring explicit thread type overrides. (#14162) Thanks @0xRaini.
|
||||
|
||||
## 2026.2.9
|
||||
|
||||
|
||||
@@ -114,7 +114,27 @@ describe("sendMessageDiscord", () => {
|
||||
await createThreadDiscord("chan1", { name: "thread" }, { rest, token: "t" });
|
||||
expect(postMock).toHaveBeenCalledWith(
|
||||
Routes.threads("chan1"),
|
||||
expect.objectContaining({ body: { name: "thread" } }),
|
||||
expect.objectContaining({
|
||||
body: expect.objectContaining({ name: "thread", type: ChannelType.PublicThread }),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
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 }),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -122,6 +125,12 @@ export async function createThreadDiscord(
|
||||
const starterContent = payload.content?.trim() ? payload.content : payload.name;
|
||||
body.message = { content: starterContent };
|
||||
}
|
||||
// When creating a standalone thread (no messageId) in a non-forum channel,
|
||||
// default to public thread (type 11). Discord defaults to private (type 12)
|
||||
// which is unexpected for most users. (#14147)
|
||||
if (!payload.messageId && !isForumLike && body.type === undefined) {
|
||||
body.type = ChannelType.PublicThread;
|
||||
}
|
||||
const route = payload.messageId
|
||||
? Routes.threads(channelId, payload.messageId)
|
||||
: Routes.threads(channelId);
|
||||
|
||||
@@ -72,6 +72,8 @@ export type DiscordThreadCreate = {
|
||||
name: string;
|
||||
autoArchiveMinutes?: number;
|
||||
content?: string;
|
||||
/** Discord thread type (default: PublicThread for standalone threads). */
|
||||
type?: number;
|
||||
};
|
||||
|
||||
export type DiscordThreadList = {
|
||||
|
||||
Reference in New Issue
Block a user