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,11 +1,10 @@
|
|||
import { PluginOptions } from "knub";
|
||||
import { GuildLogs } from "../../data/GuildLogs";
|
||||
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
||||
import { makeIoTsConfigParser } from "../../pluginUtils";
|
||||
import { LogsPlugin } from "../Logs/LogsPlugin";
|
||||
import { TimeAndDatePlugin } from "../TimeAndDate/TimeAndDatePlugin";
|
||||
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
||||
import { AutoDeletePluginType, ConfigSchema } from "./types";
|
||||
import { AutoDeletePluginType, zAutoDeleteConfig } from "./types";
|
||||
import { onMessageCreate } from "./util/onMessageCreate";
|
||||
import { onMessageDelete } from "./util/onMessageDelete";
|
||||
import { onMessageDeleteBulk } from "./util/onMessageDeleteBulk";
|
||||
|
@ -24,11 +23,11 @@ export const AutoDeletePlugin = zeppelinGuildPlugin<AutoDeletePluginType>()({
|
|||
prettyName: "Auto-delete",
|
||||
description: "Allows Zeppelin to auto-delete messages from a channel after a delay",
|
||||
configurationGuide: "Maximum deletion delay is currently 5 minutes",
|
||||
configSchema: ConfigSchema,
|
||||
configSchema: zAutoDeleteConfig,
|
||||
},
|
||||
|
||||
dependencies: () => [TimeAndDatePlugin, LogsPlugin],
|
||||
configParser: makeIoTsConfigParser(ConfigSchema),
|
||||
configParser: (input) => zAutoDeleteConfig.parse(input),
|
||||
defaultOptions,
|
||||
|
||||
beforeLoad(pluginData) {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import * as t from "io-ts";
|
||||
import { BasePluginType } from "knub";
|
||||
import { GuildLogs } from "../../data/GuildLogs";
|
||||
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
||||
import { SavedMessage } from "../../data/entities/SavedMessage";
|
||||
import { MINUTES, tDelayString } from "../../utils";
|
||||
import { MINUTES, zDelayString } from "../../utils";
|
||||
import Timeout = NodeJS.Timeout;
|
||||
import z from "zod";
|
||||
|
||||
export const MAX_DELAY = 5 * MINUTES;
|
||||
|
||||
|
@ -13,14 +13,13 @@ export interface IDeletionQueueItem {
|
|||
message: SavedMessage;
|
||||
}
|
||||
|
||||
export const ConfigSchema = t.type({
|
||||
enabled: t.boolean,
|
||||
delay: tDelayString,
|
||||
export const zAutoDeleteConfig = z.strictObject({
|
||||
enabled: z.boolean(),
|
||||
delay: zDelayString,
|
||||
});
|
||||
export type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
||||
|
||||
export interface AutoDeletePluginType extends BasePluginType {
|
||||
config: TConfigSchema;
|
||||
config: z.output<typeof zAutoDeleteConfig>;
|
||||
state: {
|
||||
guildSavedMessages: GuildSavedMessages;
|
||||
guildLogs: GuildLogs;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue