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
|
@ -1,29 +1,31 @@
|
|||
import { decorators as d, IPluginOptions, logger } from "knub";
|
||||
import { ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { Member, Channel, GuildChannel, PermissionOverwrite, Permission, Message } from "eris";
|
||||
import * as t from "io-ts";
|
||||
|
||||
// Permissions using these numbers: https://abal.moe/Eris/docs/reference (add all allowed/denied ones up)
|
||||
interface ICompanionChannel {
|
||||
channelIds: string[];
|
||||
permissions: number;
|
||||
}
|
||||
const CompanionChannel = t.type({
|
||||
channelIds: t.array(t.string),
|
||||
permissions: t.number,
|
||||
});
|
||||
type TCompanionChannel = t.TypeOf<typeof CompanionChannel>;
|
||||
|
||||
const ConfigSchema = t.type({
|
||||
channels: t.record(t.string, CompanionChannel),
|
||||
});
|
||||
type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
||||
|
||||
interface ICompanionChannelMap {
|
||||
[channelId: string]: ICompanionChannel;
|
||||
[channelId: string]: TCompanionChannel;
|
||||
}
|
||||
|
||||
interface ICompanionChannelPluginConfig {
|
||||
channels: {
|
||||
[key: string]: ICompanionChannel;
|
||||
};
|
||||
}
|
||||
|
||||
export class CompanionChannelPlugin extends ZeppelinPlugin<ICompanionChannelPluginConfig> {
|
||||
export class CompanionChannelPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||
public static pluginName = "companion_channels";
|
||||
protected static configSchema = ConfigSchema;
|
||||
|
||||
companionChannels: Map<string, ICompanionChannel> = new Map();
|
||||
companionChannels: Map<string, TCompanionChannel> = new Map();
|
||||
|
||||
getDefaultOptions(): IPluginOptions<ICompanionChannelPluginConfig> {
|
||||
getDefaultOptions(): IPluginOptions<TConfigSchema> {
|
||||
return {
|
||||
config: {
|
||||
channels: {},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue