




















1-import { parseAvailableTags, readNumberParam, readStringParam } from "../runtime-api.js";
1+import {
2+parseAvailableTags,
3+readNonNegativeIntegerParam,
4+readPositiveIntegerParam,
5+readStringParam,
6+} from "../runtime-api.js";
27import type { OpenClawConfig } from "../runtime-api.js";
38import type {
49DiscordChannelCreate,
@@ -47,12 +52,12 @@ export function readDiscordChannelCreateParams(
4752guildId: readStringParam(params, "guildId", { required: true }),
4853name: readStringParam(params, "name", { required: true }),
4954type:
50-readNumberParam(params, "channelType", { integer: true }) ??
51-readNumberParam(params, "type", { integer: true }) ??
55+readNonNegativeIntegerParam(params, "channelType") ??
56+readNonNegativeIntegerParam(params, "type") ??
5257undefined,
5358parentId: parentId ?? undefined,
5459topic: readStringParam(params, "topic") ?? undefined,
55-position: readNumberParam(params, "position", { integer: true }) ?? undefined,
60+position: readNonNegativeIntegerParam(params, "position") ?? undefined,
5661nsfw: readDiscordBooleanParam(params, "nsfw"),
5762};
5863}
@@ -63,14 +68,13 @@ export function readDiscordChannelEditParams(params: Record<string, unknown>): D
6368channelId: readStringParam(params, "channelId", { required: true }),
6469name: readStringParam(params, "name") ?? undefined,
6570topic: readStringParam(params, "topic") ?? undefined,
66-position: readNumberParam(params, "position", { integer: true }) ?? undefined,
71+position: readNonNegativeIntegerParam(params, "position") ?? undefined,
6772parentId: parentId === undefined ? undefined : parentId,
6873nsfw: readDiscordBooleanParam(params, "nsfw"),
69-rateLimitPerUser: readNumberParam(params, "rateLimitPerUser", { integer: true }) ?? undefined,
74+rateLimitPerUser: readNonNegativeIntegerParam(params, "rateLimitPerUser") ?? undefined,
7075archived: readDiscordBooleanParam(params, "archived"),
7176locked: readDiscordBooleanParam(params, "locked"),
72-autoArchiveDuration:
73-readNumberParam(params, "autoArchiveDuration", { integer: true }) ?? undefined,
77+autoArchiveDuration: readPositiveIntegerParam(params, "autoArchiveDuration") ?? undefined,
7478availableTags: parseAvailableTags(params.availableTags),
7579};
7680}
@@ -81,6 +85,6 @@ export function readDiscordChannelMoveParams(params: Record<string, unknown>): D
8185guildId: readStringParam(params, "guildId", { required: true }),
8286channelId: readStringParam(params, "channelId", { required: true }),
8387parentId: parentId === undefined ? undefined : parentId,
84-position: readNumberParam(params, "position", { integer: true }) ?? undefined,
88+position: readNonNegativeIntegerParam(params, "position") ?? undefined,
8589};
8690}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。