mirror of
https://github.com/farcasclaudiu/openclaw.git
synced 2026-06-28 21:01:43 +03:00
Discord: handle thread edit params
This commit is contained in:
@@ -322,6 +322,11 @@ export async function handleDiscordGuildAction(
|
|||||||
const rateLimitPerUser = readNumberParam(params, "rateLimitPerUser", {
|
const rateLimitPerUser = readNumberParam(params, "rateLimitPerUser", {
|
||||||
integer: true,
|
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
|
const channel = accountId
|
||||||
? await editChannelDiscord(
|
? await editChannelDiscord(
|
||||||
{
|
{
|
||||||
@@ -332,6 +337,9 @@ export async function handleDiscordGuildAction(
|
|||||||
parentId,
|
parentId,
|
||||||
nsfw,
|
nsfw,
|
||||||
rateLimitPerUser: rateLimitPerUser ?? undefined,
|
rateLimitPerUser: rateLimitPerUser ?? undefined,
|
||||||
|
archived,
|
||||||
|
locked,
|
||||||
|
autoArchiveDuration: autoArchiveDuration ?? undefined,
|
||||||
},
|
},
|
||||||
{ accountId },
|
{ accountId },
|
||||||
)
|
)
|
||||||
@@ -343,6 +351,9 @@ export async function handleDiscordGuildAction(
|
|||||||
parentId,
|
parentId,
|
||||||
nsfw,
|
nsfw,
|
||||||
rateLimitPerUser: rateLimitPerUser ?? undefined,
|
rateLimitPerUser: rateLimitPerUser ?? undefined,
|
||||||
|
archived,
|
||||||
|
locked,
|
||||||
|
autoArchiveDuration: autoArchiveDuration ?? undefined,
|
||||||
});
|
});
|
||||||
return jsonResult({ ok: true, channel });
|
return jsonResult({ ok: true, channel });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -315,6 +315,34 @@ describe("handleDiscordGuildAction - channel management", () => {
|
|||||||
parentId: undefined,
|
parentId: undefined,
|
||||||
nsfw: undefined,
|
nsfw: undefined,
|
||||||
rateLimitPerUser: 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,
|
parentId: null,
|
||||||
nsfw: undefined,
|
nsfw: undefined,
|
||||||
rateLimitPerUser: undefined,
|
rateLimitPerUser: undefined,
|
||||||
|
archived: undefined,
|
||||||
|
locked: undefined,
|
||||||
|
autoArchiveDuration: undefined,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -355,6 +386,9 @@ describe("handleDiscordGuildAction - channel management", () => {
|
|||||||
parentId: null,
|
parentId: null,
|
||||||
nsfw: undefined,
|
nsfw: undefined,
|
||||||
rateLimitPerUser: undefined,
|
rateLimitPerUser: undefined,
|
||||||
|
archived: undefined,
|
||||||
|
locked: undefined,
|
||||||
|
autoArchiveDuration: undefined,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -183,6 +183,11 @@ export async function tryHandleDiscordMessageActionGuildAdmin(params: {
|
|||||||
const rateLimitPerUser = readNumberParam(actionParams, "rateLimitPerUser", {
|
const rateLimitPerUser = readNumberParam(actionParams, "rateLimitPerUser", {
|
||||||
integer: true,
|
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(
|
return await handleDiscordAction(
|
||||||
{
|
{
|
||||||
action: "channelEdit",
|
action: "channelEdit",
|
||||||
@@ -194,6 +199,9 @@ export async function tryHandleDiscordMessageActionGuildAdmin(params: {
|
|||||||
parentId: parentId === undefined ? undefined : parentId,
|
parentId: parentId === undefined ? undefined : parentId,
|
||||||
nsfw,
|
nsfw,
|
||||||
rateLimitPerUser: rateLimitPerUser ?? undefined,
|
rateLimitPerUser: rateLimitPerUser ?? undefined,
|
||||||
|
archived,
|
||||||
|
locked,
|
||||||
|
autoArchiveDuration: autoArchiveDuration ?? undefined,
|
||||||
},
|
},
|
||||||
cfg,
|
cfg,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -61,6 +61,15 @@ export async function editChannelDiscord(
|
|||||||
if (payload.rateLimitPerUser !== undefined) {
|
if (payload.rateLimitPerUser !== undefined) {
|
||||||
body.rate_limit_per_user = payload.rateLimitPerUser;
|
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), {
|
return (await rest.patch(Routes.channel(payload.channelId), {
|
||||||
body,
|
body,
|
||||||
})) as APIChannel;
|
})) as APIChannel;
|
||||||
|
|||||||
@@ -142,6 +142,9 @@ export type DiscordChannelEdit = {
|
|||||||
parentId?: string | null;
|
parentId?: string | null;
|
||||||
nsfw?: boolean;
|
nsfw?: boolean;
|
||||||
rateLimitPerUser?: number;
|
rateLimitPerUser?: number;
|
||||||
|
archived?: boolean;
|
||||||
|
locked?: boolean;
|
||||||
|
autoArchiveDuration?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type DiscordChannelMove = {
|
export type DiscordChannelMove = {
|
||||||
|
|||||||
Reference in New Issue
Block a user