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:
parent
fafaefa1fb
commit
28692962bc
161 changed files with 1450 additions and 2105 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue