3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-07-07 19:17:19 +00:00

refactor: move defaults to config schemas

This commit is contained in:
Dragory 2025-05-23 01:12:52 +00:00
parent 09eb8e92f2
commit 83d35052c3
No known key found for this signature in database
91 changed files with 450 additions and 888 deletions

View file

@ -1,4 +1,4 @@
import { PluginOptions, guildPlugin } from "knub";
import { guildPlugin } from "knub";
import { GuildArchives } from "../../data/GuildArchives.js";
import { GuildLogs } from "../../data/GuildLogs.js";
import { GuildMutes } from "../../data/GuildMutes.js";
@ -9,20 +9,12 @@ import { SpamPluginType, zSpamConfig } from "./types.js";
import { clearOldRecentActions } from "./util/clearOldRecentActions.js";
import { onMessageCreate } from "./util/onMessageCreate.js";
const defaultOptions: PluginOptions<SpamPluginType> = {
config: {
max_censor: null,
max_messages: null,
max_mentions: null,
max_links: null,
max_attachments: null,
max_emojis: null,
max_newlines: null,
max_duplicates: null,
max_characters: null,
max_voice_moves: null,
},
overrides: [
export const SpamPlugin = guildPlugin<SpamPluginType>()({
name: "spam",
dependencies: () => [LogsPlugin],
configSchema: zSpamConfig,
defaultOverrides: [
{
level: ">=50",
config: {
@ -38,14 +30,6 @@ const defaultOptions: PluginOptions<SpamPluginType> = {
},
},
],
};
export const SpamPlugin = guildPlugin<SpamPluginType>()({
name: "spam",
dependencies: () => [LogsPlugin],
configParser: (input) => zSpamConfig.parse(input),
defaultOptions,
// prettier-ignore
events: [

View file

@ -18,16 +18,16 @@ const zBaseSingleSpamConfig = z.strictObject({
export type TBaseSingleSpamConfig = z.infer<typeof zBaseSingleSpamConfig>;
export const zSpamConfig = z.strictObject({
max_censor: zBaseSingleSpamConfig.nullable(),
max_messages: zBaseSingleSpamConfig.nullable(),
max_mentions: zBaseSingleSpamConfig.nullable(),
max_links: zBaseSingleSpamConfig.nullable(),
max_attachments: zBaseSingleSpamConfig.nullable(),
max_emojis: zBaseSingleSpamConfig.nullable(),
max_newlines: zBaseSingleSpamConfig.nullable(),
max_duplicates: zBaseSingleSpamConfig.nullable(),
max_characters: zBaseSingleSpamConfig.nullable(),
max_voice_moves: zBaseSingleSpamConfig.nullable(),
max_censor: zBaseSingleSpamConfig.nullable().default(null),
max_messages: zBaseSingleSpamConfig.nullable().default(null),
max_mentions: zBaseSingleSpamConfig.nullable().default(null),
max_links: zBaseSingleSpamConfig.nullable().default(null),
max_attachments: zBaseSingleSpamConfig.nullable().default(null),
max_emojis: zBaseSingleSpamConfig.nullable().default(null),
max_newlines: zBaseSingleSpamConfig.nullable().default(null),
max_duplicates: zBaseSingleSpamConfig.nullable().default(null),
max_characters: zBaseSingleSpamConfig.nullable().default(null),
max_voice_moves: zBaseSingleSpamConfig.nullable().default(null),
});
export enum RecentActionType {
@ -52,7 +52,7 @@ export interface IRecentAction<T> {
}
export interface SpamPluginType extends BasePluginType {
config: z.infer<typeof zSpamConfig>;
configSchema: typeof zSpamConfig;
state: {
logs: GuildLogs;
archives: GuildArchives;