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
|
@ -2,7 +2,6 @@ import { PluginOptions } from "knub";
|
|||
import { GuildLogs } from "../../data/GuildLogs";
|
||||
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
||||
import { GuildSlowmodes } from "../../data/GuildSlowmodes";
|
||||
import { makeIoTsConfigParser } from "../../pluginUtils";
|
||||
import { SECONDS } from "../../utils";
|
||||
import { LogsPlugin } from "../Logs/LogsPlugin";
|
||||
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
||||
|
@ -11,7 +10,7 @@ import { SlowmodeDisableCmd } from "./commands/SlowmodeDisableCmd";
|
|||
import { SlowmodeGetCmd } from "./commands/SlowmodeGetCmd";
|
||||
import { SlowmodeListCmd } from "./commands/SlowmodeListCmd";
|
||||
import { SlowmodeSetCmd } from "./commands/SlowmodeSetCmd";
|
||||
import { ConfigSchema, SlowmodePluginType } from "./types";
|
||||
import { SlowmodePluginType, zSlowmodeConfig } from "./types";
|
||||
import { clearExpiredSlowmodes } from "./util/clearExpiredSlowmodes";
|
||||
import { onMessageCreate } from "./util/onMessageCreate";
|
||||
|
||||
|
@ -41,7 +40,7 @@ export const SlowmodePlugin = zeppelinGuildPlugin<SlowmodePluginType>()({
|
|||
showInDocs: true,
|
||||
info: {
|
||||
prettyName: "Slowmode",
|
||||
configSchema: ConfigSchema,
|
||||
configSchema: zSlowmodeConfig,
|
||||
},
|
||||
|
||||
// prettier-ignore
|
||||
|
@ -49,7 +48,7 @@ export const SlowmodePlugin = zeppelinGuildPlugin<SlowmodePluginType>()({
|
|||
LogsPlugin,
|
||||
],
|
||||
|
||||
configParser: makeIoTsConfigParser(ConfigSchema),
|
||||
configParser: (input) => zSlowmodeConfig.parse(input),
|
||||
defaultOptions,
|
||||
|
||||
// prettier-ignore
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
import * as t from "io-ts";
|
||||
import { BasePluginType, guildPluginEventListener, guildPluginMessageCommand } from "knub";
|
||||
import z from "zod";
|
||||
import { GuildLogs } from "../../data/GuildLogs";
|
||||
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
||||
import { GuildSlowmodes } from "../../data/GuildSlowmodes";
|
||||
import { SlowmodeChannel } from "../../data/entities/SlowmodeChannel";
|
||||
|
||||
export const ConfigSchema = t.type({
|
||||
use_native_slowmode: t.boolean,
|
||||
|
||||
can_manage: t.boolean,
|
||||
is_affected: t.boolean,
|
||||
export const zSlowmodeConfig = z.strictObject({
|
||||
use_native_slowmode: z.boolean(),
|
||||
|
||||
can_manage: z.boolean(),
|
||||
is_affected: z.boolean(),
|
||||
});
|
||||
export type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
||||
|
||||
export interface SlowmodePluginType extends BasePluginType {
|
||||
config: TConfigSchema;
|
||||
config: z.infer<typeof zSlowmodeConfig>;
|
||||
state: {
|
||||
slowmodes: GuildSlowmodes;
|
||||
savedMessages: GuildSavedMessages;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue