mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-18 07:35:02 +00:00
Add io-ts config schemas to all guild plugins
This commit is contained in:
parent
21402b2ea4
commit
039f0452fb
23 changed files with 373 additions and 294 deletions
|
@ -22,6 +22,13 @@ import { GuildScheduledPosts } from "../data/GuildScheduledPosts";
|
|||
import moment, { Moment } from "moment-timezone";
|
||||
import { GuildLogs } from "../data/GuildLogs";
|
||||
import { LogType } from "../data/LogType";
|
||||
import * as t from "io-ts";
|
||||
|
||||
const ConfigSchema = t.type({
|
||||
can_post: t.boolean,
|
||||
});
|
||||
type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
||||
|
||||
const fsp = fs.promises;
|
||||
|
||||
const COLOR_MATCH_REGEX = /^#?([0-9a-f]{6})$/;
|
||||
|
@ -29,12 +36,9 @@ const COLOR_MATCH_REGEX = /^#?([0-9a-f]{6})$/;
|
|||
const SCHEDULED_POST_CHECK_INTERVAL = 15 * SECONDS;
|
||||
const SCHEDULED_POST_PREVIEW_TEXT_LENGTH = 50;
|
||||
|
||||
interface IPostPluginConfig {
|
||||
can_post: boolean;
|
||||
}
|
||||
|
||||
export class PostPlugin extends ZeppelinPlugin<IPostPluginConfig> {
|
||||
export class PostPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||
public static pluginName = "post";
|
||||
protected static configSchema = ConfigSchema;
|
||||
|
||||
protected savedMessages: GuildSavedMessages;
|
||||
protected scheduledPosts: GuildScheduledPosts;
|
||||
|
@ -54,7 +58,7 @@ export class PostPlugin extends ZeppelinPlugin<IPostPluginConfig> {
|
|||
clearTimeout(this.scheduledPostLoopTimeout);
|
||||
}
|
||||
|
||||
getDefaultOptions(): IPluginOptions<IPostPluginConfig> {
|
||||
getDefaultOptions(): IPluginOptions<TConfigSchema> {
|
||||
return {
|
||||
config: {
|
||||
can_post: false,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue