mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-06-08 00:05:01 +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
|
@ -11,22 +11,15 @@ import { RoleButtonsPluginType, zRoleButtonsConfig } from "./types.js";
|
|||
export const RoleButtonsPlugin = guildPlugin<RoleButtonsPluginType>()({
|
||||
name: "role_buttons",
|
||||
|
||||
defaultOptions: {
|
||||
config: {
|
||||
buttons: {},
|
||||
can_reset: false,
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
level: ">=100",
|
||||
config: {
|
||||
can_reset: true,
|
||||
},
|
||||
configSchema: zRoleButtonsConfig,
|
||||
defaultOverrides: [
|
||||
{
|
||||
level: ">=100",
|
||||
config: {
|
||||
can_reset: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
configParser: (input) => zRoleButtonsConfig.parse(input),
|
||||
},
|
||||
],
|
||||
|
||||
dependencies: () => [LogsPlugin, RoleManagerPlugin],
|
||||
|
||||
|
|
|
@ -67,8 +67,8 @@ export type TRoleButtonsConfigItem = z.infer<typeof zRoleButtonsConfigItem>;
|
|||
|
||||
export const zRoleButtonsConfig = z
|
||||
.strictObject({
|
||||
buttons: zBoundedRecord(z.record(zBoundedCharacters(1, 16), zRoleButtonsConfigItem), 0, 100),
|
||||
can_reset: z.boolean(),
|
||||
buttons: zBoundedRecord(z.record(zBoundedCharacters(1, 16), zRoleButtonsConfigItem), 0, 100).default({}),
|
||||
can_reset: z.boolean().default(false),
|
||||
})
|
||||
.refine(
|
||||
(parsed) => {
|
||||
|
@ -91,7 +91,7 @@ export const zRoleButtonsConfig = z
|
|||
);
|
||||
|
||||
export interface RoleButtonsPluginType extends BasePluginType {
|
||||
config: z.infer<typeof zRoleButtonsConfig>;
|
||||
configSchema: typeof zRoleButtonsConfig;
|
||||
state: {
|
||||
roleButtons: GuildRoleButtons;
|
||||
common: pluginUtils.PluginPublicInterface<typeof CommonPlugin>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue