mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
refactor: replace io-ts with zod
This commit is contained in:
parent
fafaefa1fb
commit
28692962bc
161 changed files with 1450 additions and 2105 deletions
|
@ -1,6 +1,6 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import * as t from "io-ts";
|
||||
import { erisAllowedMentionsToDjsMentionOptions } from "src/utils/erisAllowedMentionsToDjsMentionOptions";
|
||||
import z from "zod";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import {
|
||||
createTypedTemplateSafeValueContainer,
|
||||
|
@ -12,10 +12,12 @@ import {
|
|||
chunkMessageLines,
|
||||
isTruthy,
|
||||
messageLink,
|
||||
tAllowedMentions,
|
||||
tNormalizedNullOptional,
|
||||
validateAndParseMessageContent,
|
||||
verboseChannelMention,
|
||||
zAllowedMentions,
|
||||
zBoundedCharacters,
|
||||
zNullishToUndefined,
|
||||
zSnowflake
|
||||
} from "../../../utils";
|
||||
import { messageIsEmpty } from "../../../utils/messageIsEmpty";
|
||||
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
|
||||
|
@ -23,14 +25,14 @@ import { InternalPosterPlugin } from "../../InternalPoster/InternalPosterPlugin"
|
|||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
import { automodAction } from "../helpers";
|
||||
|
||||
export const AlertAction = automodAction({
|
||||
configType: t.type({
|
||||
channel: t.string,
|
||||
text: t.string,
|
||||
allowed_mentions: tNormalizedNullOptional(tAllowedMentions),
|
||||
}),
|
||||
const configSchema = z.object({
|
||||
channel: zSnowflake,
|
||||
text: zBoundedCharacters(1, 4000),
|
||||
allowed_mentions: zNullishToUndefined(zAllowedMentions.nullable().default(null)),
|
||||
});
|
||||
|
||||
defaultConfig: {},
|
||||
export const AlertAction = automodAction({
|
||||
configSchema,
|
||||
|
||||
async apply({ pluginData, contexts, actionConfig, ruleName, matchResult }) {
|
||||
const channel = pluginData.guild.channels.cache.get(actionConfig.channel as Snowflake);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue