3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 20:35:02 +00:00

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,11 +1,10 @@
import { PluginOptions } from "knub";
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
import { makeIoTsConfigParser } from "../../pluginUtils";
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
import { SaveMessagesToDBCmd } from "./commands/SaveMessagesToDB";
import { SavePinsToDBCmd } from "./commands/SavePinsToDB";
import { MessageCreateEvt, MessageDeleteBulkEvt, MessageDeleteEvt, MessageUpdateEvt } from "./events/SaveMessagesEvts";
import { ConfigSchema, MessageSaverPluginType } from "./types";
import { MessageSaverPluginType, zMessageSaverConfig } from "./types";
const defaultOptions: PluginOptions<MessageSaverPluginType> = {
config: {
@ -25,7 +24,7 @@ export const MessageSaverPlugin = zeppelinGuildPlugin<MessageSaverPluginType>()(
name: "message_saver",
showInDocs: false,
configParser: makeIoTsConfigParser(ConfigSchema),
configParser: (input) => zMessageSaverConfig.parse(input),
defaultOptions,
// prettier-ignore

View file

@ -1,14 +1,13 @@
import * as t from "io-ts";
import { BasePluginType, guildPluginEventListener, guildPluginMessageCommand } from "knub";
import z from "zod";
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
export const ConfigSchema = t.type({
can_manage: t.boolean,
export const zMessageSaverConfig = z.strictObject({
can_manage: z.boolean(),
});
export type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
export interface MessageSaverPluginType extends BasePluginType {
config: TConfigSchema;
config: z.infer<typeof zMessageSaverConfig>;
state: {
savedMessages: GuildSavedMessages;
};