mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-14 22:05:01 +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,7 +1,6 @@
|
|||
import { PluginOptions } from "knub";
|
||||
import { GuildLogs } from "../../data/GuildLogs";
|
||||
import { GuildPersistedData } from "../../data/GuildPersistedData";
|
||||
import { makeIoTsConfigParser } from "../../pluginUtils";
|
||||
import { trimPluginDescription } from "../../utils";
|
||||
import { GuildMemberCachePlugin } from "../GuildMemberCache/GuildMemberCachePlugin";
|
||||
import { LogsPlugin } from "../Logs/LogsPlugin";
|
||||
|
@ -9,7 +8,7 @@ import { RoleManagerPlugin } from "../RoleManager/RoleManagerPlugin";
|
|||
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
||||
import { LoadDataEvt } from "./events/LoadDataEvt";
|
||||
import { StoreDataEvt } from "./events/StoreDataEvt";
|
||||
import { ConfigSchema, PersistPluginType } from "./types";
|
||||
import { PersistPluginType, zPersistConfig } from "./types";
|
||||
|
||||
const defaultOptions: PluginOptions<PersistPluginType> = {
|
||||
config: {
|
||||
|
@ -28,11 +27,11 @@ export const PersistPlugin = zeppelinGuildPlugin<PersistPluginType>()({
|
|||
Re-apply roles or nicknames for users when they rejoin the server.
|
||||
Mute roles are re-applied automatically, this plugin is not required for that.
|
||||
`),
|
||||
configSchema: ConfigSchema,
|
||||
configSchema: zPersistConfig,
|
||||
},
|
||||
|
||||
dependencies: () => [LogsPlugin, RoleManagerPlugin, GuildMemberCachePlugin],
|
||||
configParser: makeIoTsConfigParser(ConfigSchema),
|
||||
configParser: (input) => zPersistConfig.parse(input),
|
||||
defaultOptions,
|
||||
|
||||
// prettier-ignore
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
import * as t from "io-ts";
|
||||
import { BasePluginType, guildPluginEventListener } from "knub";
|
||||
import z from "zod";
|
||||
import { GuildLogs } from "../../data/GuildLogs";
|
||||
import { GuildPersistedData } from "../../data/GuildPersistedData";
|
||||
import { zSnowflake } from "../../utils";
|
||||
|
||||
export const ConfigSchema = t.type({
|
||||
persisted_roles: t.array(t.string),
|
||||
persist_nicknames: t.boolean,
|
||||
persist_voice_mutes: t.boolean, // Deprecated, here to not break old configs
|
||||
export const zPersistConfig = z.strictObject({
|
||||
persisted_roles: z.array(zSnowflake),
|
||||
persist_nicknames: z.boolean(),
|
||||
persist_voice_mutes: z.boolean(),
|
||||
});
|
||||
export type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
||||
|
||||
export interface PersistPluginType extends BasePluginType {
|
||||
config: TConfigSchema;
|
||||
config: z.infer<typeof zPersistConfig>;
|
||||
|
||||
state: {
|
||||
persistedData: GuildPersistedData;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue