mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-07-08 03:27:20 +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
|
@ -13,14 +13,11 @@ import { inGuildTz } from "./functions/inGuildTz.js";
|
|||
import { inMemberTz } from "./functions/inMemberTz.js";
|
||||
import { TimeAndDatePluginType, zTimeAndDateConfig } from "./types.js";
|
||||
|
||||
const defaultOptions: PluginOptions<TimeAndDatePluginType> = {
|
||||
config: {
|
||||
timezone: "Etc/UTC",
|
||||
can_set_timezone: false,
|
||||
date_formats: defaultDateFormats,
|
||||
},
|
||||
export const TimeAndDatePlugin = guildPlugin<TimeAndDatePluginType>()({
|
||||
name: "time_and_date",
|
||||
|
||||
overrides: [
|
||||
configSchema: zTimeAndDateConfig,
|
||||
defaultOverrides: [
|
||||
{
|
||||
level: ">=50",
|
||||
config: {
|
||||
|
@ -28,13 +25,6 @@ const defaultOptions: PluginOptions<TimeAndDatePluginType> = {
|
|||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const TimeAndDatePlugin = guildPlugin<TimeAndDatePluginType>()({
|
||||
name: "time_and_date",
|
||||
|
||||
configParser: (input) => zTimeAndDateConfig.parse(input),
|
||||
defaultOptions,
|
||||
|
||||
// prettier-ignore
|
||||
messageCommands: [
|
||||
|
|
|
@ -10,13 +10,13 @@ import { defaultDateFormats } from "./defaultDateFormats.js";
|
|||
const zDateFormatKeys = z.enum(keys(defaultDateFormats) as U.ListOf<keyof typeof defaultDateFormats>);
|
||||
|
||||
export const zTimeAndDateConfig = z.strictObject({
|
||||
timezone: zValidTimezone(z.string()),
|
||||
date_formats: z.record(zDateFormatKeys, z.string()).nullable(),
|
||||
can_set_timezone: z.boolean(),
|
||||
timezone: zValidTimezone(z.string()).default("Etc/UTC"),
|
||||
date_formats: z.record(zDateFormatKeys, z.string()).nullable().default(defaultDateFormats),
|
||||
can_set_timezone: z.boolean().default(false),
|
||||
});
|
||||
|
||||
export interface TimeAndDatePluginType extends BasePluginType {
|
||||
config: z.infer<typeof zTimeAndDateConfig>;
|
||||
configSchema: typeof zTimeAndDateConfig;
|
||||
state: {
|
||||
memberTimezones: GuildMemberTimezones;
|
||||
common: pluginUtils.PluginPublicInterface<typeof CommonPlugin>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue