mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-19 18:39:20 -05:00
Discord: handle thread edit params
This commit is contained in:
@@ -322,6 +322,11 @@ export async function handleDiscordGuildAction(
|
||||
const rateLimitPerUser = readNumberParam(params, "rateLimitPerUser", {
|
||||
integer: true,
|
||||
});
|
||||
const archived = typeof params.archived === "boolean" ? params.archived : undefined;
|
||||
const locked = typeof params.locked === "boolean" ? params.locked : undefined;
|
||||
const autoArchiveDuration = readNumberParam(params, "autoArchiveDuration", {
|
||||
integer: true,
|
||||
});
|
||||
const channel = accountId
|
||||
? await editChannelDiscord(
|
||||
{
|
||||
@@ -332,6 +337,9 @@ export async function handleDiscordGuildAction(
|
||||
parentId,
|
||||
nsfw,
|
||||
rateLimitPerUser: rateLimitPerUser ?? undefined,
|
||||
archived,
|
||||
locked,
|
||||
autoArchiveDuration: autoArchiveDuration ?? undefined,
|
||||
},
|
||||
{ accountId },
|
||||
)
|
||||
@@ -343,6 +351,9 @@ export async function handleDiscordGuildAction(
|
||||
parentId,
|
||||
nsfw,
|
||||
rateLimitPerUser: rateLimitPerUser ?? undefined,
|
||||
archived,
|
||||
locked,
|
||||
autoArchiveDuration: autoArchiveDuration ?? undefined,
|
||||
});
|
||||
return jsonResult({ ok: true, channel });
|
||||
}
|
||||
|
||||
@@ -315,6 +315,34 @@ describe("handleDiscordGuildAction - channel management", () => {
|
||||
parentId: undefined,
|
||||
nsfw: undefined,
|
||||
rateLimitPerUser: undefined,
|
||||
archived: undefined,
|
||||
locked: undefined,
|
||||
autoArchiveDuration: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
it("forwards thread edit fields", async () => {
|
||||
await handleDiscordGuildAction(
|
||||
"channelEdit",
|
||||
{
|
||||
channelId: "C1",
|
||||
archived: true,
|
||||
locked: false,
|
||||
autoArchiveDuration: 1440,
|
||||
},
|
||||
channelsEnabled,
|
||||
);
|
||||
expect(editChannelDiscord).toHaveBeenCalledWith({
|
||||
channelId: "C1",
|
||||
name: undefined,
|
||||
topic: undefined,
|
||||
position: undefined,
|
||||
parentId: undefined,
|
||||
nsfw: undefined,
|
||||
rateLimitPerUser: undefined,
|
||||
archived: true,
|
||||
locked: false,
|
||||
autoArchiveDuration: 1440,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -335,6 +363,9 @@ describe("handleDiscordGuildAction - channel management", () => {
|
||||
parentId: null,
|
||||
nsfw: undefined,
|
||||
rateLimitPerUser: undefined,
|
||||
archived: undefined,
|
||||
locked: undefined,
|
||||
autoArchiveDuration: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -355,6 +386,9 @@ describe("handleDiscordGuildAction - channel management", () => {
|
||||
parentId: null,
|
||||
nsfw: undefined,
|
||||
rateLimitPerUser: undefined,
|
||||
archived: undefined,
|
||||
locked: undefined,
|
||||
autoArchiveDuration: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -183,6 +183,11 @@ export async function tryHandleDiscordMessageActionGuildAdmin(params: {
|
||||
const rateLimitPerUser = readNumberParam(actionParams, "rateLimitPerUser", {
|
||||
integer: true,
|
||||
});
|
||||
const archived = typeof actionParams.archived === "boolean" ? actionParams.archived : undefined;
|
||||
const locked = typeof actionParams.locked === "boolean" ? actionParams.locked : undefined;
|
||||
const autoArchiveDuration = readNumberParam(actionParams, "autoArchiveDuration", {
|
||||
integer: true,
|
||||
});
|
||||
return await handleDiscordAction(
|
||||
{
|
||||
action: "channelEdit",
|
||||
@@ -194,6 +199,9 @@ export async function tryHandleDiscordMessageActionGuildAdmin(params: {
|
||||
parentId: parentId === undefined ? undefined : parentId,
|
||||
nsfw,
|
||||
rateLimitPerUser: rateLimitPerUser ?? undefined,
|
||||
archived,
|
||||
locked,
|
||||
autoArchiveDuration: autoArchiveDuration ?? undefined,
|
||||
},
|
||||
cfg,
|
||||
);
|
||||
|
||||
@@ -61,6 +61,15 @@ export async function editChannelDiscord(
|
||||
if (payload.rateLimitPerUser !== undefined) {
|
||||
body.rate_limit_per_user = payload.rateLimitPerUser;
|
||||
}
|
||||
if (payload.archived !== undefined) {
|
||||
body.archived = payload.archived;
|
||||
}
|
||||
if (payload.locked !== undefined) {
|
||||
body.locked = payload.locked;
|
||||
}
|
||||
if (payload.autoArchiveDuration !== undefined) {
|
||||
body.auto_archive_duration = payload.autoArchiveDuration;
|
||||
}
|
||||
return (await rest.patch(Routes.channel(payload.channelId), {
|
||||
body,
|
||||
})) as APIChannel;
|
||||
|
||||
@@ -142,6 +142,9 @@ export type DiscordChannelEdit = {
|
||||
parentId?: string | null;
|
||||
nsfw?: boolean;
|
||||
rateLimitPerUser?: number;
|
||||
archived?: boolean;
|
||||
locked?: boolean;
|
||||
autoArchiveDuration?: number;
|
||||
};
|
||||
|
||||
export type DiscordChannelMove = {
|
||||
|
||||
Reference in New Issue
Block a user