3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

fix: tweaks to config types

This commit is contained in:
Dragory 2024-01-27 12:46:48 +02:00
parent 6110b8190c
commit b0a9cf1bcd
No known key found for this signature in database
5 changed files with 8 additions and 6 deletions

View file

@ -27,7 +27,7 @@ import { automodAction } from "../helpers";
const configSchema = z.object({ const configSchema = z.object({
channel: zSnowflake, channel: zSnowflake,
text: zBoundedCharacters(1, 4000), text: zBoundedCharacters(0, 4000),
allowed_mentions: zNullishToUndefined(zAllowedMentions.nullable().default(null)), allowed_mentions: zNullishToUndefined(zAllowedMentions.nullable().default(null)),
}); });

View file

@ -2,7 +2,7 @@ import { PermissionsBitField, PermissionsString } from "discord.js";
import { U } from "ts-toolbelt"; import { U } from "ts-toolbelt";
import z from "zod"; import z from "zod";
import { TemplateSafeValueContainer, renderTemplate } from "../../../templateFormatter"; import { TemplateSafeValueContainer, renderTemplate } from "../../../templateFormatter";
import { isValidSnowflake, keys, noop, zBoundedCharacters, zSnowflake } from "../../../utils"; import { isValidSnowflake, keys, noop, zBoundedCharacters } from "../../../utils";
import { import {
guildToTemplateSafeGuild, guildToTemplateSafeGuild,
savedMessageToTemplateSafeSavedMessage, savedMessageToTemplateSafeSavedMessage,
@ -66,8 +66,8 @@ const allPermissionNames = [...permissionNames, ...legacyPermissionNames] as con
export const ChangePermsAction = automodAction({ export const ChangePermsAction = automodAction({
configSchema: z.strictObject({ configSchema: z.strictObject({
target: zBoundedCharacters(1, 255), target: zBoundedCharacters(1, 2000),
channel: zBoundedCharacters(1, 255).nullable().default(null), channel: zBoundedCharacters(1, 2000).nullable().default(null),
perms: z.record( perms: z.record(
z.enum(allPermissionNames), z.enum(allPermissionNames),
z.boolean().nullable(), z.boolean().nullable(),

View file

@ -14,7 +14,7 @@ interface MatchResultType {
const regexCache = new WeakMap<any, RegExp[]>(); const regexCache = new WeakMap<any, RegExp[]>();
const configSchema = z.strictObject({ const configSchema = z.strictObject({
words: z.array(z.string().max(2000)).max(512), words: z.array(z.string().max(2000)).max(1024),
case_sensitive: z.boolean().default(false), case_sensitive: z.boolean().default(false),
only_full_words: z.boolean().default(true), only_full_words: z.boolean().default(true),
normalize: z.boolean().default(false), normalize: z.boolean().default(false),

View file

@ -69,7 +69,7 @@ export const zAutomodConfig = z.strictObject({
rules: zBoundedRecord( rules: zBoundedRecord(
z.record(z.string().max(100), zRule), z.record(z.string().max(100), zRule),
0, 0,
100, 255,
), ),
antiraid_levels: z.array(z.string().max(100)).max(10), antiraid_levels: z.array(z.string().max(100)).max(10),
can_set_antiraid: z.boolean(), can_set_antiraid: z.boolean(),

View file

@ -289,6 +289,8 @@ export type StrictMessageContent = {
export const zMessageContent = z.union([zBoundedCharacters(0, 4000), zStrictMessageContent]); export const zMessageContent = z.union([zBoundedCharacters(0, 4000), zStrictMessageContent]);
export type MessageContent = string | StrictMessageContent;
export function validateAndParseMessageContent(input: unknown): StrictMessageContent { export function validateAndParseMessageContent(input: unknown): StrictMessageContent {
if (input == null) { if (input == null) {
return {}; return {};