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:
parent
09eb8e92f2
commit
83d35052c3
91 changed files with 450 additions and 888 deletions
|
@ -9,13 +9,12 @@ import { MassRemoveRoleCmd } from "./commands/MassRemoveRoleCmd.js";
|
|||
import { RemoveRoleCmd } from "./commands/RemoveRoleCmd.js";
|
||||
import { RolesPluginType, zRolesConfig } from "./types.js";
|
||||
|
||||
const defaultOptions: PluginOptions<RolesPluginType> = {
|
||||
config: {
|
||||
can_assign: false,
|
||||
can_mass_assign: false,
|
||||
assignable_roles: [],
|
||||
},
|
||||
overrides: [
|
||||
export const RolesPlugin = guildPlugin<RolesPluginType>()({
|
||||
name: "roles",
|
||||
|
||||
dependencies: () => [LogsPlugin, RoleManagerPlugin],
|
||||
configSchema: zRolesConfig,
|
||||
defaultOverrides: [
|
||||
{
|
||||
level: ">=50",
|
||||
config: {
|
||||
|
@ -29,14 +28,6 @@ const defaultOptions: PluginOptions<RolesPluginType> = {
|
|||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const RolesPlugin = guildPlugin<RolesPluginType>()({
|
||||
name: "roles",
|
||||
|
||||
dependencies: () => [LogsPlugin, RoleManagerPlugin],
|
||||
configParser: (input) => zRolesConfig.parse(input),
|
||||
defaultOptions,
|
||||
|
||||
// prettier-ignore
|
||||
messageCommands: [
|
||||
|
|
|
@ -4,13 +4,13 @@ import { GuildLogs } from "../../data/GuildLogs.js";
|
|||
import { CommonPlugin } from "../Common/CommonPlugin.js";
|
||||
|
||||
export const zRolesConfig = z.strictObject({
|
||||
can_assign: z.boolean(),
|
||||
can_mass_assign: z.boolean(),
|
||||
assignable_roles: z.array(z.string()).max(100),
|
||||
can_assign: z.boolean().default(false),
|
||||
can_mass_assign: z.boolean().default(false),
|
||||
assignable_roles: z.array(z.string()).max(100).default([]),
|
||||
});
|
||||
|
||||
export interface RolesPluginType extends BasePluginType {
|
||||
config: z.infer<typeof zRolesConfig>;
|
||||
configSchema: typeof zRolesConfig;
|
||||
state: {
|
||||
logs: GuildLogs;
|
||||
common: pluginUtils.PluginPublicInterface<typeof CommonPlugin>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue