3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-07-08 03:27:20 +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

@ -2,10 +2,9 @@ import { PluginOptions } from "knub";
import { Queue } from "../../Queue";
import { GuildNicknameHistory } from "../../data/GuildNicknameHistory";
import { UsernameHistory } from "../../data/UsernameHistory";
import { makeIoTsConfigParser } from "../../pluginUtils";
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
import { NamesCmd } from "./commands/NamesCmd";
import { ConfigSchema, NameHistoryPluginType } from "./types";
import { NameHistoryPluginType, zNameHistoryConfig } from "./types";
const defaultOptions: PluginOptions<NameHistoryPluginType> = {
config: {
@ -25,7 +24,7 @@ export const NameHistoryPlugin = zeppelinGuildPlugin<NameHistoryPluginType>()({
name: "name_history",
showInDocs: false,
configParser: makeIoTsConfigParser(ConfigSchema),
configParser: (input) => zNameHistoryConfig.parse(input),
defaultOptions,
// prettier-ignore

View file

@ -1,16 +1,15 @@
import * as t from "io-ts";
import { BasePluginType, guildPluginEventListener, guildPluginMessageCommand } from "knub";
import z from "zod";
import { Queue } from "../../Queue";
import { GuildNicknameHistory } from "../../data/GuildNicknameHistory";
import { UsernameHistory } from "../../data/UsernameHistory";
export const ConfigSchema = t.type({
can_view: t.boolean,
export const zNameHistoryConfig = z.strictObject({
can_view: z.boolean(),
});
export type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
export interface NameHistoryPluginType extends BasePluginType {
config: TConfigSchema;
config: z.infer<typeof zNameHistoryConfig>;
state: {
nicknameHistory: GuildNicknameHistory;
usernameHistory: UsernameHistory;