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
|
@ -1,5 +1,4 @@
|
|||
import { CooldownManager, PluginOptions, guildPlugin } from "knub";
|
||||
import DefaultLogMessages from "../../data/DefaultLogMessages.json" with { type: "json" };
|
||||
import { CooldownManager, guildPlugin } from "knub";
|
||||
import { GuildArchives } from "../../data/GuildArchives.js";
|
||||
import { GuildCases } from "../../data/GuildCases.js";
|
||||
import { GuildLogs } from "../../data/GuildLogs.js";
|
||||
|
@ -115,17 +114,12 @@ function getCasesPlugin(): Promise<any> {
|
|||
return import("../Cases/CasesPlugin.js") as Promise<any>;
|
||||
}
|
||||
|
||||
const defaultOptions: PluginOptions<LogsPluginType> = {
|
||||
config: {
|
||||
channels: {},
|
||||
format: DefaultLogMessages,
|
||||
ping_user: true,
|
||||
allow_user_mentions: false,
|
||||
timestamp_format: "[<t:]X[>]",
|
||||
include_embed_timestamp: true,
|
||||
},
|
||||
export const LogsPlugin = guildPlugin<LogsPluginType>()({
|
||||
name: "logs",
|
||||
|
||||
overrides: [
|
||||
dependencies: async () => [TimeAndDatePlugin, InternalPosterPlugin, (await getCasesPlugin()).CasesPlugin],
|
||||
configSchema: zLogsConfig,
|
||||
defaultOverrides: [
|
||||
{
|
||||
level: ">=50",
|
||||
config: {
|
||||
|
@ -134,14 +128,6 @@ const defaultOptions: PluginOptions<LogsPluginType> = {
|
|||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const LogsPlugin = guildPlugin<LogsPluginType>()({
|
||||
name: "logs",
|
||||
|
||||
dependencies: async () => [TimeAndDatePlugin, InternalPosterPlugin, (await getCasesPlugin()).CasesPlugin],
|
||||
configParser: (input) => zLogsConfig.parse(input),
|
||||
defaultOptions,
|
||||
|
||||
events: [
|
||||
LogsGuildMemberAddEvt,
|
||||
|
|
|
@ -21,6 +21,7 @@ import {
|
|||
TemplateSafeUnknownUser,
|
||||
TemplateSafeUser,
|
||||
} from "../../utils/templateSafeObjects.js";
|
||||
import DefaultLogMessages from "../../data/DefaultLogMessages.json" with { type: "json" };
|
||||
|
||||
const DEFAULT_BATCH_TIME = 1000;
|
||||
const MIN_BATCH_TIME = 250;
|
||||
|
@ -53,20 +54,20 @@ const zLogChannelMap = z.record(zSnowflake, zLogChannel);
|
|||
export type TLogChannelMap = z.infer<typeof zLogChannelMap>;
|
||||
|
||||
export const zLogsConfig = z.strictObject({
|
||||
channels: zLogChannelMap,
|
||||
format: zLogFormats,
|
||||
channels: zLogChannelMap.default({}),
|
||||
format: zLogFormats.default(DefaultLogMessages),
|
||||
// Legacy/deprecated, if below is false mentions wont actually ping. In case you really want the old behavior, set below to true
|
||||
ping_user: z.boolean(),
|
||||
allow_user_mentions: z.boolean(),
|
||||
timestamp_format: z.string().nullable(),
|
||||
include_embed_timestamp: z.boolean(),
|
||||
ping_user: z.boolean().default(true),
|
||||
allow_user_mentions: z.boolean().default(false),
|
||||
timestamp_format: z.string().nullable().default("[<t:]X[>]"),
|
||||
include_embed_timestamp: z.boolean().default(true),
|
||||
});
|
||||
|
||||
// Hacky way of allowing a """null""" default value for config.format.timestamp due to legacy io-ts reasons
|
||||
export const FORMAT_NO_TIMESTAMP = "__NO_TIMESTAMP__";
|
||||
|
||||
export interface LogsPluginType extends BasePluginType {
|
||||
config: z.infer<typeof zLogsConfig>;
|
||||
configSchema: typeof zLogsConfig;
|
||||
state: {
|
||||
guildLogs: GuildLogs;
|
||||
savedMessages: GuildSavedMessages;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue