mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
Update to Knub 29. Set up config types for Knub.
This commit is contained in:
parent
3e974e84b3
commit
94ef7b8ee0
6 changed files with 28 additions and 6 deletions
6
backend/package-lock.json
generated
6
backend/package-lock.json
generated
|
@ -2776,9 +2776,9 @@
|
|||
}
|
||||
},
|
||||
"knub": {
|
||||
"version": "28.0.0",
|
||||
"resolved": "https://registry.npmjs.org/knub/-/knub-28.0.0.tgz",
|
||||
"integrity": "sha512-dhLjlQP32AbkXoD0tUFrqa8/Emh/U5lvYXNCz+bIWiAlzYr1cQKRuh9qNjAL944sCWmtfhKXVMXRFS99P6M7qw==",
|
||||
"version": "29.0.0",
|
||||
"resolved": "https://registry.npmjs.org/knub/-/knub-29.0.0.tgz",
|
||||
"integrity": "sha512-jnWG/wuh2PogBDwwrYKGw0rI29quk0NEsC/inoOi0l5YbtzoIpK6Qj9BsZf/vjgtIeTemiJySlQZ7HeailYexQ==",
|
||||
"requires": {
|
||||
"escape-string-regexp": "^2.0.0",
|
||||
"knub-command-manager": "^7.0.0",
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
"humanize-duration": "^3.15.0",
|
||||
"io-ts": "^2.0.0",
|
||||
"js-yaml": "^3.13.1",
|
||||
"knub": "^28.0.0",
|
||||
"knub": "^29.0.0",
|
||||
"knub-command-manager": "^7.0.0",
|
||||
"last-commit-log": "^2.1.0",
|
||||
"lodash.chunk": "^4.2.0",
|
||||
|
|
|
@ -4,7 +4,7 @@ import yaml from "js-yaml";
|
|||
import fs from "fs";
|
||||
const fsp = fs.promises;
|
||||
|
||||
import { Knub, logger, PluginError, Plugin } from "knub";
|
||||
import { Knub, logger, PluginError, Plugin, IGlobalConfig, IGuildConfig } from "knub";
|
||||
import { SimpleError } from "./SimpleError";
|
||||
|
||||
import DiscordRESTError from "eris/lib/errors/DiscordRESTError"; // tslint:disable-line
|
||||
|
@ -75,6 +75,7 @@ import { customArgumentTypes } from "./customArgumentTypes";
|
|||
import { errorMessage, successMessage } from "./utils";
|
||||
import { startUptimeCounter } from "./uptime";
|
||||
import { AllowedGuilds } from "./data/AllowedGuilds";
|
||||
import { IZeppelinGuildConfig, IZeppelinGlobalConfig } from "./types";
|
||||
|
||||
logger.info("Connecting to database");
|
||||
connect().then(async conn => {
|
||||
|
@ -93,7 +94,7 @@ connect().then(async conn => {
|
|||
const allowedGuilds = new AllowedGuilds();
|
||||
const guildConfigs = new Configs();
|
||||
|
||||
const bot = new Knub(client, {
|
||||
const bot = new Knub<IZeppelinGuildConfig, IZeppelinGlobalConfig>(client, {
|
||||
plugins: availablePlugins,
|
||||
globalPlugins: availableGlobalPlugins,
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import { deepKeyIntersect, isSnowflake, isUnicodeEmoji, resolveMember, resolveUs
|
|||
import { Member, User } from "eris";
|
||||
import { performance } from "perf_hooks";
|
||||
import { decodeAndValidateStrict, StrictValidationError } from "../validatorUtils";
|
||||
import { TZeppelinKnub } from "../types";
|
||||
|
||||
const SLOW_RESOLVE_THRESHOLD = 1500;
|
||||
|
||||
|
@ -15,6 +16,8 @@ export class GlobalZeppelinPlugin<TConfig extends {} = IBasePluginConfig> extend
|
|||
public static configSchema: t.TypeC<any>;
|
||||
public static dependencies = [];
|
||||
|
||||
protected readonly knub: TZeppelinKnub;
|
||||
|
||||
/**
|
||||
* Since we want to do type checking without creating instances of every plugin,
|
||||
* we need a static version of getDefaultOptions(). This static version is then,
|
||||
|
|
|
@ -23,6 +23,8 @@ import DiscordRESTError from "eris/lib/errors/DiscordRESTError"; // tslint:disab
|
|||
import { performance } from "perf_hooks";
|
||||
import { decodeAndValidateStrict, StrictValidationError, validate } from "../validatorUtils";
|
||||
import { SimpleCache } from "../SimpleCache";
|
||||
import { Knub } from "knub/dist/Knub";
|
||||
import { TZeppelinKnub } from "../types";
|
||||
|
||||
const SLOW_RESOLVE_THRESHOLD = 1500;
|
||||
|
||||
|
@ -67,6 +69,8 @@ export class ZeppelinPlugin<TConfig extends {} = IBasePluginConfig> extends Plug
|
|||
public static configSchema: t.TypeC<any>;
|
||||
public static dependencies = [];
|
||||
|
||||
protected readonly knub: TZeppelinKnub;
|
||||
|
||||
protected throwPluginRuntimeError(message: string) {
|
||||
throw new PluginRuntimeError(message, this.runtimePluginName, this.guildId);
|
||||
}
|
||||
|
|
14
backend/src/types.ts
Normal file
14
backend/src/types.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
import { IGlobalConfig, IGuildConfig, Knub } from "knub";
|
||||
|
||||
// Remove this tslint exception once there are properties in the interface
|
||||
// tslint:disable-next-line
|
||||
export interface IZeppelinGuildConfig extends IGuildConfig {
|
||||
// To fill
|
||||
}
|
||||
|
||||
export interface IZeppelinGlobalConfig extends IGlobalConfig {
|
||||
url: string;
|
||||
owners?: string[];
|
||||
}
|
||||
|
||||
export type TZeppelinKnub = Knub<IZeppelinGuildConfig, IZeppelinGlobalConfig>;
|
Loading…
Add table
Reference in a new issue