mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-18 23:55:02 +00:00
Switch from ajv to io-ts for config validation; validate configs on save in the API/dashboard; start work on creating io-ts schemas for all plugins
This commit is contained in:
parent
1ecce52973
commit
3f4724b699
14 changed files with 256 additions and 41 deletions
|
@ -5,20 +5,23 @@ import { GuildAutoReactions } from "../data/GuildAutoReactions";
|
|||
import { Message } from "eris";
|
||||
import { customEmojiRegex, errorMessage, isEmoji, successMessage } from "../utils";
|
||||
import { ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import * as t from "io-ts";
|
||||
|
||||
interface IAutoReactionsPluginConfig {
|
||||
can_manage: boolean;
|
||||
}
|
||||
const configSchema = t.type({
|
||||
can_manage: t.boolean,
|
||||
});
|
||||
type TConfigSchema = t.TypeOf<typeof configSchema>;
|
||||
|
||||
export class AutoReactionsPlugin extends ZeppelinPlugin<IAutoReactionsPluginConfig> {
|
||||
export class AutoReactionsPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||
public static pluginName = "auto_reactions";
|
||||
protected static configSchema = configSchema;
|
||||
|
||||
protected savedMessages: GuildSavedMessages;
|
||||
protected autoReactions: GuildAutoReactions;
|
||||
|
||||
private onMessageCreateFn;
|
||||
|
||||
getDefaultOptions(): IPluginOptions<IAutoReactionsPluginConfig> {
|
||||
getDefaultOptions(): IPluginOptions<TConfigSchema> {
|
||||
return {
|
||||
config: {
|
||||
can_manage: false,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue