refactor: replace io-ts with zod

This commit is contained in:
Dragory 2024-01-14 14:25:42 +00:00
parent fafaefa1fb
commit 28692962bc
No known key found for this signature in database
161 changed files with 1450 additions and 2105 deletions

View file

@ -1,16 +1,16 @@
import { GuildTextBasedChannel, MessageCreateOptions, PermissionsBitField, Snowflake, User } from "discord.js";
import * as t from "io-ts";
import z from "zod";
import { TemplateSafeValueContainer, renderTemplate } from "../../../templateFormatter";
import {
convertDelayStringToMS,
noop,
renderRecursively,
tDelayString,
tMessageContent,
tNullable,
unique,
validateAndParseMessageContent,
verboseChannelMention,
zBoundedCharacters,
zDelayString,
zMessageContent
} from "../../../utils";
import { hasDiscordPermissions } from "../../../utils/hasDiscordPermissions";
import { messageIsEmpty } from "../../../utils/messageIsEmpty";
@ -20,17 +20,15 @@ import { automodAction } from "../helpers";
import { AutomodContext } from "../types";
export const ReplyAction = automodAction({
configType: t.union([
t.string,
t.type({
text: tMessageContent,
auto_delete: tNullable(t.union([tDelayString, t.number])),
inline: tNullable(t.boolean),
configSchema: z.union([
zBoundedCharacters(0, 4000),
z.strictObject({
text: zMessageContent,
auto_delete: z.union([zDelayString, z.number()]).nullable().default(null),
inline: z.boolean().default(false),
}),
]),
defaultConfig: {},
async apply({ pluginData, contexts, actionConfig, ruleName }) {
const contextsWithTextChannels = contexts
.filter((c) => c.message?.channel_id)