mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-06-17 11:25:03 +00:00
refactor: move defaults to config schemas
This commit is contained in:
parent
09eb8e92f2
commit
83d35052c3
91 changed files with 450 additions and 888 deletions
|
@ -16,18 +16,11 @@ import { LogsPlugin } from "../Logs/LogsPlugin.js";
|
|||
import { runEvent } from "./functions/runEvent.js";
|
||||
import { CustomEventsPluginType, zCustomEventsConfig } from "./types.js";
|
||||
|
||||
const defaultOptions = {
|
||||
config: {
|
||||
events: {},
|
||||
},
|
||||
};
|
||||
|
||||
export const CustomEventsPlugin = guildPlugin<CustomEventsPluginType>()({
|
||||
name: "custom_events",
|
||||
|
||||
dependencies: () => [LogsPlugin],
|
||||
configParser: (input) => zCustomEventsConfig.parse(input),
|
||||
defaultOptions,
|
||||
configSchema: zCustomEventsConfig,
|
||||
|
||||
beforeStart(pluginData) {
|
||||
pluginData.state.common = pluginData.getPlugin(CommonPlugin);
|
||||
|
|
|
@ -37,11 +37,11 @@ export const zCustomEvent = z.strictObject({
|
|||
export type TCustomEvent = z.infer<typeof zCustomEvent>;
|
||||
|
||||
export const zCustomEventsConfig = z.strictObject({
|
||||
events: zBoundedRecord(z.record(zBoundedCharacters(0, 100), zCustomEvent), 0, 100),
|
||||
events: zBoundedRecord(z.record(zBoundedCharacters(0, 100), zCustomEvent), 0, 100).default({}),
|
||||
});
|
||||
|
||||
export interface CustomEventsPluginType extends BasePluginType {
|
||||
config: z.infer<typeof zCustomEventsConfig>;
|
||||
configSchema: typeof zCustomEventsConfig;
|
||||
state: {
|
||||
clearTriggers: () => void;
|
||||
common: pluginUtils.PluginPublicInterface<typeof CommonPlugin>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue