mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
WIP
This commit is contained in:
parent
a0fa21f0f5
commit
7e3f9ebd11
40 changed files with 118 additions and 119 deletions
26
backend/package-lock.json
generated
26
backend/package-lock.json
generated
|
@ -2962,21 +2962,27 @@
|
|||
}
|
||||
},
|
||||
"knub": {
|
||||
"version": "29.0.0",
|
||||
"resolved": "https://registry.npmjs.org/knub/-/knub-29.0.0.tgz",
|
||||
"integrity": "sha512-jnWG/wuh2PogBDwwrYKGw0rI29quk0NEsC/inoOi0l5YbtzoIpK6Qj9BsZf/vjgtIeTemiJySlQZ7HeailYexQ==",
|
||||
"version": "30.0.0-beta.2",
|
||||
"resolved": "https://registry.npmjs.org/knub/-/knub-30.0.0-beta.2.tgz",
|
||||
"integrity": "sha512-t4zQifhGfzD34ZMfjEzEVwLMD6lxySoKIocnfY9UAYSJrjLZyAMIkFlm0Y537CZjzm67VNy5FZfiQi9u1NMgIQ==",
|
||||
"requires": {
|
||||
"escape-string-regexp": "^2.0.0",
|
||||
"knub-command-manager": "^7.0.0",
|
||||
"lodash.clonedeep": "^4.5.0",
|
||||
"knub-command-manager": "^8.1.0",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"ts-essentials": "^2.0.12"
|
||||
"ts-essentials": "^6.0.7"
|
||||
},
|
||||
"dependencies": {
|
||||
"escape-string-regexp": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz",
|
||||
"integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w=="
|
||||
},
|
||||
"knub-command-manager": {
|
||||
"version": "8.1.0",
|
||||
"resolved": "https://registry.npmjs.org/knub-command-manager/-/knub-command-manager-8.1.0.tgz",
|
||||
"integrity": "sha512-kIQhEGgMtrCIoc8GrkUUJV4yKmbtC0MDpx/dqXi8cNQ8gTlDlQj8+PkM5NnzDkNvrX7cw2/Te10auD7jne3vsQ==",
|
||||
"requires": {
|
||||
"escape-string-regexp": "^2.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -4908,9 +4914,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"ts-essentials": {
|
||||
"version": "2.0.12",
|
||||
"resolved": "https://registry.npmjs.org/ts-essentials/-/ts-essentials-2.0.12.tgz",
|
||||
"integrity": "sha512-3IVX4nI6B5cc31/GFFE+i8ey/N2eA0CZDbo6n0yrz0zDX8ZJ8djmU1p+XRz7G3is0F3bB3pu2pAroFdAWQKU3w=="
|
||||
"version": "6.0.7",
|
||||
"resolved": "https://registry.npmjs.org/ts-essentials/-/ts-essentials-6.0.7.tgz",
|
||||
"integrity": "sha512-2E4HIIj4tQJlIHuATRHayv0EfMGK3ris/GRk1E3CFnsZzeNV+hUmelbaTZHLtXaZppM5oLhHRtO04gINC4Jusw=="
|
||||
},
|
||||
"tsc-watch": {
|
||||
"version": "4.0.0",
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
"humanize-duration": "^3.15.0",
|
||||
"io-ts": "^2.0.0",
|
||||
"js-yaml": "^3.13.1",
|
||||
"knub": "^29.0.0",
|
||||
"knub": "^30.0.0-beta.2",
|
||||
"knub-command-manager": "^7.0.0",
|
||||
"last-commit-log": "^2.1.0",
|
||||
"lodash.chunk": "^4.2.0",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import express from "express";
|
||||
import { availablePlugins } from "../plugins/availablePlugins";
|
||||
import { ZeppelinPlugin } from "../plugins/ZeppelinPlugin";
|
||||
import { ZeppelinPluginClass } from "../plugins/ZeppelinPluginClass";
|
||||
import { notFound } from "./responses";
|
||||
import { dropPropertiesByName, indentLines } from "../utils";
|
||||
import { IPluginCommandConfig, Plugin, pluginUtils } from "knub";
|
||||
|
@ -75,7 +75,7 @@ export function initDocs(app: express.Express) {
|
|||
};
|
||||
});
|
||||
|
||||
const defaultOptions = (pluginClass as typeof ZeppelinPlugin).getStaticDefaultOptions();
|
||||
const defaultOptions = (pluginClass as typeof ZeppelinPluginClass).getStaticDefaultOptions();
|
||||
|
||||
const configSchema = pluginClass.configSchema && formatConfigSchema(pluginClass.configSchema);
|
||||
|
||||
|
|
|
@ -4,10 +4,10 @@ import { pipe } from "fp-ts/lib/pipeable";
|
|||
import { fold } from "fp-ts/lib/Either";
|
||||
import { PathReporter } from "io-ts/lib/PathReporter";
|
||||
import { availablePlugins } from "./plugins/availablePlugins";
|
||||
import { ZeppelinPlugin } from "./plugins/ZeppelinPlugin";
|
||||
import { ZeppelinPluginClass } from "./plugins/ZeppelinPluginClass";
|
||||
import { decodeAndValidateStrict, StrictValidationError } from "./validatorUtils";
|
||||
|
||||
const pluginNameToClass = new Map<string, typeof ZeppelinPlugin>();
|
||||
const pluginNameToClass = new Map<string, typeof ZeppelinPluginClass>();
|
||||
for (const pluginClass of availablePlugins) {
|
||||
// @ts-ignore
|
||||
pluginNameToClass.set(pluginClass.pluginName, pluginClass);
|
||||
|
|
|
@ -77,10 +77,10 @@ for (const [i, part] of actualVersionParts.entries()) {
|
|||
import moment from "moment-timezone";
|
||||
moment.tz.setDefault("UTC");
|
||||
|
||||
import { Client, TextableChannel, TextChannel } from "eris";
|
||||
import { Client, TextChannel } from "eris";
|
||||
import { connect } from "./data/db";
|
||||
import { availablePlugins, availableGlobalPlugins, basePlugins } from "./plugins/availablePlugins";
|
||||
import { ZeppelinPlugin } from "./plugins/ZeppelinPlugin";
|
||||
import { ZeppelinPluginClass } from "./plugins/ZeppelinPluginClass";
|
||||
import { customArgumentTypes } from "./customArgumentTypes";
|
||||
import { errorMessage, isDiscordHTTPError, isDiscordRESTError, successMessage } from "./utils";
|
||||
import { startUptimeCounter } from "./uptime";
|
||||
|
@ -91,7 +91,7 @@ import { GuildLogs } from "./data/GuildLogs";
|
|||
import { LogType } from "./data/LogType";
|
||||
|
||||
logger.info("Connecting to database");
|
||||
connect().then(async conn => {
|
||||
connect().then(async () => {
|
||||
const client = new Client(`Bot ${process.env.TOKEN}`, {
|
||||
getAllUsers: false,
|
||||
restMode: true,
|
||||
|
@ -108,7 +108,7 @@ connect().then(async conn => {
|
|||
const guildConfigs = new Configs();
|
||||
|
||||
const bot = new Knub<IZeppelinGuildConfig, IZeppelinGlobalConfig>(client, {
|
||||
plugins: availablePlugins,
|
||||
guildPlugins: availablePlugins,
|
||||
globalPlugins: availableGlobalPlugins,
|
||||
|
||||
options: {
|
||||
|
@ -126,9 +126,9 @@ connect().then(async conn => {
|
|||
const configuredPlugins = guildConfig.plugins || {};
|
||||
const pluginNames: string[] = Array.from(this.plugins.keys());
|
||||
const plugins: Array<typeof Plugin> = Array.from(this.plugins.values());
|
||||
const zeppelinPlugins: Array<typeof ZeppelinPlugin> = plugins.filter(
|
||||
p => p.prototype instanceof ZeppelinPlugin,
|
||||
) as Array<typeof ZeppelinPlugin>;
|
||||
const zeppelinPlugins: Array<typeof ZeppelinPluginClass> = plugins.filter(
|
||||
p => p.prototype instanceof ZeppelinPluginClass,
|
||||
) as Array<typeof ZeppelinPluginClass>;
|
||||
|
||||
const enabledBasePlugins = pluginNames.filter(n => basePlugins.includes(n));
|
||||
const explicitlyEnabledPlugins = pluginNames.filter(pluginName => {
|
||||
|
@ -176,13 +176,13 @@ connect().then(async conn => {
|
|||
|
||||
sendSuccessMessageFn(channel, body) {
|
||||
const guildId = channel instanceof TextChannel ? channel.guild.id : undefined;
|
||||
const emoji = guildId ? bot.getGuildData(guildId).config.success_emoji : undefined;
|
||||
const emoji = guildId ? bot.getLoadedGuild(guildId).config.success_emoji : undefined;
|
||||
channel.createMessage(successMessage(body, emoji));
|
||||
},
|
||||
|
||||
sendErrorMessageFn(channel, body) {
|
||||
const guildId = channel instanceof TextChannel ? channel.guild.id : undefined;
|
||||
const emoji = guildId ? bot.getGuildData(guildId).config.error_emoji : undefined;
|
||||
const emoji = guildId ? bot.getLoadedGuild(guildId).config.error_emoji : undefined;
|
||||
channel.createMessage(errorMessage(body, emoji));
|
||||
},
|
||||
},
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { IPluginOptions, logger } from "knub";
|
||||
import * as t from "io-ts";
|
||||
import { ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { ZeppelinPluginClass } from "./ZeppelinPluginClass";
|
||||
import { GuildSavedMessages } from "../data/GuildSavedMessages";
|
||||
import { SavedMessage } from "../data/entities/SavedMessage";
|
||||
import { convertDelayStringToMS, MINUTES, sorter, stripObjectToScalars, tDelayString } from "../utils";
|
||||
|
@ -28,7 +28,7 @@ interface IDeletionQueueItem {
|
|||
|
||||
const MAX_DELAY = 5 * MINUTES;
|
||||
|
||||
export class AntiRaid extends ZeppelinPlugin<TConfigSchema> {
|
||||
export class AntiRaid extends ZeppelinPluginClass<TConfigSchema> {
|
||||
public static pluginName = "auto_delete";
|
||||
public static showInDocs = true;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { IPluginOptions, logger } from "knub";
|
||||
import * as t from "io-ts";
|
||||
import { ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { ZeppelinPluginClass } from "./ZeppelinPluginClass";
|
||||
import { GuildSavedMessages } from "../data/GuildSavedMessages";
|
||||
import { SavedMessage } from "../data/entities/SavedMessage";
|
||||
import { convertDelayStringToMS, MINUTES, sorter, stripObjectToScalars, tDelayString } from "../utils";
|
||||
|
@ -21,7 +21,7 @@ interface IDeletionQueueItem {
|
|||
|
||||
const MAX_DELAY = 5 * MINUTES;
|
||||
|
||||
export class AutoDeletePlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||
export class AutoDeletePlugin extends ZeppelinPluginClass<TConfigSchema> {
|
||||
public static pluginName = "auto_delete";
|
||||
public static showInDocs = true;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import { SavedMessage } from "../data/entities/SavedMessage";
|
|||
import { GuildAutoReactions } from "../data/GuildAutoReactions";
|
||||
import { Message } from "eris";
|
||||
import { customEmojiRegex, errorMessage, isDiscordRESTError, isEmoji } from "../utils";
|
||||
import { CommandInfo, trimPluginDescription, ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { CommandInfo, trimPluginDescription, ZeppelinPluginClass } from "./ZeppelinPluginClass";
|
||||
import * as t from "io-ts";
|
||||
import { GuildLogs } from "../data/GuildLogs";
|
||||
import { LogType } from "../data/LogType";
|
||||
|
@ -14,7 +14,7 @@ const ConfigSchema = t.type({
|
|||
});
|
||||
type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
||||
|
||||
export class AutoReactionsPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||
export class AutoReactionsPlugin extends ZeppelinPluginClass<TConfigSchema> {
|
||||
public static pluginName = "auto_reactions";
|
||||
public static configSchema = ConfigSchema;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { trimPluginDescription, ZeppelinPlugin } from "../ZeppelinPlugin";
|
||||
import { trimPluginDescription, ZeppelinPluginClass } from "../ZeppelinPluginClass";
|
||||
import * as t from "io-ts";
|
||||
import {
|
||||
convertDelayStringToMS,
|
||||
|
@ -209,7 +209,7 @@ const RAID_SPAM_IDENTIFIER = "raid";
|
|||
* call addRecentAction() directly. These are then checked by matchRuleToMessage() and matchOtherSpamInRule() to detect
|
||||
* spam.
|
||||
*/
|
||||
export class AutomodPlugin extends ZeppelinPlugin<TConfigSchema, ICustomOverrides> {
|
||||
export class AutomodPlugin extends ZeppelinPluginClass<TConfigSchema, ICustomOverrides> {
|
||||
public static pluginName = "automod";
|
||||
public static configSchema = ConfigSchema;
|
||||
public static dependencies = ["mod_actions", "mutes", "logs"];
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { PluginInfo, trimPluginDescription } from "../ZeppelinPlugin";
|
||||
import { PluginInfo, trimPluginDescription } from "../ZeppelinPluginClass";
|
||||
|
||||
export const pluginInfo: PluginInfo = {
|
||||
prettyName: "Automod",
|
||||
|
|
|
@ -4,7 +4,7 @@ import { GuildChannel, Message, TextChannel } from "eris";
|
|||
import moment from "moment-timezone";
|
||||
import { createChunkedMessage, errorMessage, noop, sorter, successMessage, tNullable } from "../utils";
|
||||
import { ReactionRolesPlugin } from "./ReactionRoles";
|
||||
import { ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { ZeppelinPluginClass } from "./ZeppelinPluginClass";
|
||||
import { GuildArchives } from "../data/GuildArchives";
|
||||
import { GlobalZeppelinPlugin } from "./GlobalZeppelinPlugin";
|
||||
import * as t from "io-ts";
|
||||
|
@ -222,7 +222,7 @@ export class BotControlPlugin extends GlobalZeppelinPlugin<TConfigSchema> {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!(pluginInstance instanceof ZeppelinPlugin)) {
|
||||
if (!(pluginInstance instanceof ZeppelinPluginClass)) {
|
||||
msg.channel.createMessage(errorMessage(`Plugin is not a Zeppelin plugin`));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import { CaseTypes } from "../data/CaseTypes";
|
|||
import { Case } from "../data/entities/Case";
|
||||
import moment from "moment-timezone";
|
||||
import { CaseTypeColors } from "../data/CaseTypeColors";
|
||||
import { PluginInfo, trimPluginDescription, ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { PluginInfo, trimPluginDescription, ZeppelinPluginClass } from "./ZeppelinPluginClass";
|
||||
import { GuildArchives } from "../data/GuildArchives";
|
||||
import { IPluginOptions, logger } from "knub";
|
||||
import { GuildLogs } from "../data/GuildLogs";
|
||||
|
@ -44,7 +44,7 @@ export type CaseNoteArgs = {
|
|||
noteDetails?: string[];
|
||||
};
|
||||
|
||||
export class CasesPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||
export class CasesPlugin extends ZeppelinPluginClass<TConfigSchema> {
|
||||
public static pluginName = "cases";
|
||||
public static configSchema = ConfigSchema;
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import {
|
|||
import { ZalgoRegex } from "../data/Zalgo";
|
||||
import { GuildSavedMessages } from "../data/GuildSavedMessages";
|
||||
import { SavedMessage } from "../data/entities/SavedMessage";
|
||||
import { trimPluginDescription, ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { trimPluginDescription, ZeppelinPluginClass } from "./ZeppelinPluginClass";
|
||||
import cloneDeep from "lodash.clonedeep";
|
||||
import * as t from "io-ts";
|
||||
import { TSafeRegex } from "../validatorUtils";
|
||||
|
@ -36,7 +36,7 @@ const ConfigSchema = t.type({
|
|||
});
|
||||
type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
||||
|
||||
export class CensorPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||
export class CensorPlugin extends ZeppelinPluginClass<TConfigSchema> {
|
||||
public static pluginName = "censor";
|
||||
public static configSchema = ConfigSchema;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import { decorators as d, ICommandContext, logger } from "knub";
|
|||
import { GlobalZeppelinPlugin } from "./GlobalZeppelinPlugin";
|
||||
import { Attachment, GuildChannel, Message, TextChannel } from "eris";
|
||||
import { confirm, downloadFile, errorMessage, noop, SECONDS, trimLines } from "../utils";
|
||||
import { ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { ZeppelinPluginClass } from "./ZeppelinPluginClass";
|
||||
import moment from "moment-timezone";
|
||||
import https from "https";
|
||||
import fs from "fs";
|
||||
|
@ -13,7 +13,7 @@ const MAX_MESSAGES_PER_FETCH = 100;
|
|||
const PROGRESS_UPDATE_INTERVAL = 5 * SECONDS;
|
||||
const MAX_ATTACHMENT_REHOST_SIZE = 1024 * 1024 * 8;
|
||||
|
||||
export class ChannelArchiverPlugin extends ZeppelinPlugin {
|
||||
export class ChannelArchiverPlugin extends ZeppelinPluginClass {
|
||||
public static pluginName = "channel_archiver";
|
||||
public static showInDocs = false;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { decorators as d, IPluginOptions, logger } from "knub";
|
||||
import { trimPluginDescription, ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { trimPluginDescription, ZeppelinPluginClass } from "./ZeppelinPluginClass";
|
||||
import { Member, Channel, GuildChannel, PermissionOverwrite, Permission, Message, TextChannel } from "eris";
|
||||
import * as t from "io-ts";
|
||||
import { tNullable } from "../utils";
|
||||
|
@ -26,7 +26,7 @@ const defaultCompanionChannelOpts: Partial<TCompanionChannelOpts> = {
|
|||
enabled: true,
|
||||
};
|
||||
|
||||
export class CompanionChannelPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||
export class CompanionChannelPlugin extends ZeppelinPluginClass<TConfigSchema> {
|
||||
public static pluginName = "companion_channels";
|
||||
public static configSchema = ConfigSchema;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { ZeppelinPluginClass } from "./ZeppelinPluginClass";
|
||||
import { IPluginOptions } from "knub";
|
||||
import { Message, TextChannel, VoiceChannel } from "eris";
|
||||
import { renderTemplate } from "../templateFormatter";
|
||||
|
@ -68,7 +68,7 @@ type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
|||
|
||||
class ActionError extends Error {}
|
||||
|
||||
export class CustomEventsPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||
export class CustomEventsPlugin extends ZeppelinPluginClass<TConfigSchema> {
|
||||
public static pluginName = "custom_events";
|
||||
public static showInDocs = false;
|
||||
public static dependencies = ["cases"];
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import moment from "moment-timezone";
|
||||
import { ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { ZeppelinPluginClass } from "./ZeppelinPluginClass";
|
||||
import { Configs } from "../data/Configs";
|
||||
import { logger } from "knub";
|
||||
import { GlobalZeppelinPlugin } from "./GlobalZeppelinPlugin";
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { ZeppelinPluginClass } from "./ZeppelinPluginClass";
|
||||
import { AllowedGuilds } from "../data/AllowedGuilds";
|
||||
import { MINUTES } from "../utils";
|
||||
|
||||
export class GuildInfoSaverPlugin extends ZeppelinPlugin {
|
||||
export class GuildInfoSaverPlugin extends ZeppelinPluginClass {
|
||||
public static pluginName = "guild_info_saver";
|
||||
public static showInDocs = false;
|
||||
protected allowedGuilds: AllowedGuilds;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { decorators as d, IPluginOptions, getInviteLink, logger } from "knub";
|
||||
import { trimPluginDescription, ZeppelinPlugin, CommandInfo } from "./ZeppelinPlugin";
|
||||
import { trimPluginDescription, ZeppelinPluginClass, CommandInfo } from "./ZeppelinPluginClass";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { Message, Member, Guild, TextableChannel, VoiceChannel, Channel, User } from "eris";
|
||||
import { GuildVCAlerts } from "../data/GuildVCAlerts";
|
||||
|
@ -15,7 +15,7 @@ type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
|||
|
||||
const ALERT_LOOP_TIME = 30 * SECONDS;
|
||||
|
||||
export class LocatePlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||
export class LocatePlugin extends ZeppelinPluginClass<TConfigSchema> {
|
||||
public static pluginName = "locate_user";
|
||||
public static configSchema = ConfigSchema;
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import { GuildSavedMessages } from "../data/GuildSavedMessages";
|
|||
import { SavedMessage } from "../data/entities/SavedMessage";
|
||||
import { GuildArchives } from "../data/GuildArchives";
|
||||
import { GuildCases } from "../data/GuildCases";
|
||||
import { ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { ZeppelinPluginClass } from "./ZeppelinPluginClass";
|
||||
import { renderTemplate, TemplateParseError } from "../templateFormatter";
|
||||
import cloneDeep from "lodash.clonedeep";
|
||||
import * as t from "io-ts";
|
||||
|
@ -56,7 +56,7 @@ const ConfigSchema = t.type({
|
|||
});
|
||||
type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
||||
|
||||
export class LogsPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||
export class LogsPlugin extends ZeppelinPluginClass<TConfigSchema> {
|
||||
public static pluginName = "logs";
|
||||
public static configSchema = ConfigSchema;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import { Plugin, decorators as d, IPluginOptions } from "knub";
|
|||
import { GuildChannel, Message, TextChannel } from "eris";
|
||||
import { GuildSavedMessages } from "../data/GuildSavedMessages";
|
||||
import { successMessage } from "../utils";
|
||||
import { ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { ZeppelinPluginClass } from "./ZeppelinPluginClass";
|
||||
import * as t from "io-ts";
|
||||
|
||||
const ConfigSchema = t.type({
|
||||
|
@ -10,7 +10,7 @@ const ConfigSchema = t.type({
|
|||
});
|
||||
type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
||||
|
||||
export class MessageSaverPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||
export class MessageSaverPlugin extends ZeppelinPluginClass<TConfigSchema> {
|
||||
public static pluginName = "message_saver";
|
||||
public static showInDocs = false;
|
||||
public static configSchema = ConfigSchema;
|
||||
|
|
|
@ -25,7 +25,7 @@ import { GuildMutes } from "../data/GuildMutes";
|
|||
import { CaseTypes } from "../data/CaseTypes";
|
||||
import { GuildLogs } from "../data/GuildLogs";
|
||||
import { LogType } from "../data/LogType";
|
||||
import { trimPluginDescription, ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { trimPluginDescription, ZeppelinPluginClass } from "./ZeppelinPluginClass";
|
||||
import { Case } from "../data/entities/Case";
|
||||
import { renderTemplate } from "../templateFormatter";
|
||||
import { CaseArgs, CasesPlugin } from "./Cases";
|
||||
|
@ -125,7 +125,7 @@ export interface BanOptions {
|
|||
deleteMessageDays?: number;
|
||||
}
|
||||
|
||||
export class ModActionsPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||
export class ModActionsPlugin extends ZeppelinPluginClass<TConfigSchema> {
|
||||
public static pluginName = "mod_actions";
|
||||
public static dependencies = ["cases", "mutes"];
|
||||
public static configSchema = ConfigSchema;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Member, Message, TextChannel, User } from "eris";
|
||||
import { GuildCases } from "../data/GuildCases";
|
||||
import moment from "moment-timezone";
|
||||
import { ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { ZeppelinPluginClass } from "./ZeppelinPluginClass";
|
||||
import { GuildMutes } from "../data/GuildMutes";
|
||||
import {
|
||||
chunkMessageLines,
|
||||
|
@ -75,7 +75,7 @@ const EXPIRED_MUTE_CHECK_INTERVAL = 60 * 1000;
|
|||
let FIRST_CHECK_TIME = Date.now();
|
||||
const FIRST_CHECK_INCREMENT = 5 * 1000;
|
||||
|
||||
export class MutesPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||
export class MutesPlugin extends ZeppelinPluginClass<TConfigSchema> {
|
||||
public static pluginName = "mutes";
|
||||
public static configSchema = ConfigSchema;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import { decorators as d, IPluginOptions } from "knub";
|
|||
import { GuildNicknameHistory, MAX_NICKNAME_ENTRIES_PER_USER } from "../data/GuildNicknameHistory";
|
||||
import { Member, Message } from "eris";
|
||||
import { createChunkedMessage, disableCodeBlocks } from "../utils";
|
||||
import { ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { ZeppelinPluginClass } from "./ZeppelinPluginClass";
|
||||
import { MAX_USERNAME_ENTRIES_PER_USER, UsernameHistory } from "../data/UsernameHistory";
|
||||
import * as t from "io-ts";
|
||||
|
||||
|
@ -11,7 +11,7 @@ const ConfigSchema = t.type({
|
|||
});
|
||||
type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
||||
|
||||
export class NameHistoryPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||
export class NameHistoryPlugin extends ZeppelinPluginClass<TConfigSchema> {
|
||||
public static pluginName = "name_history";
|
||||
public static showInDocs = false;
|
||||
public static configSchema = ConfigSchema;
|
||||
|
|
|
@ -5,7 +5,7 @@ import { Member, MemberOptions } from "eris";
|
|||
import { GuildLogs } from "../data/GuildLogs";
|
||||
import { LogType } from "../data/LogType";
|
||||
import { stripObjectToScalars } from "../utils";
|
||||
import { trimPluginDescription, ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { trimPluginDescription, ZeppelinPluginClass } from "./ZeppelinPluginClass";
|
||||
import * as t from "io-ts";
|
||||
|
||||
const ConfigSchema = t.type({
|
||||
|
@ -15,7 +15,7 @@ const ConfigSchema = t.type({
|
|||
});
|
||||
type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
||||
|
||||
export class PersistPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||
export class PersistPlugin extends ZeppelinPluginClass<TConfigSchema> {
|
||||
public static pluginName = "persist";
|
||||
public static configSchema = ConfigSchema;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import { Message, Role, TextableChannel } from "eris";
|
|||
import { GuildPingableRoles } from "../data/GuildPingableRoles";
|
||||
import { PingableRole } from "../data/entities/PingableRole";
|
||||
import { errorMessage, successMessage } from "../utils";
|
||||
import { ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { ZeppelinPluginClass } from "./ZeppelinPluginClass";
|
||||
import * as t from "io-ts";
|
||||
|
||||
const ConfigSchema = t.type({
|
||||
|
@ -13,7 +13,7 @@ type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
|||
|
||||
const TIMEOUT = 10 * 1000;
|
||||
|
||||
export class PingableRolesPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||
export class PingableRolesPlugin extends ZeppelinPluginClass<TConfigSchema> {
|
||||
public static pluginName = "pingable_roles";
|
||||
public static configSchema = ConfigSchema;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import {
|
|||
DAYS,
|
||||
} from "../utils";
|
||||
import { GuildSavedMessages } from "../data/GuildSavedMessages";
|
||||
import { ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { ZeppelinPluginClass } from "./ZeppelinPluginClass";
|
||||
|
||||
import fs from "fs";
|
||||
import { GuildScheduledPosts } from "../data/GuildScheduledPosts";
|
||||
|
@ -45,7 +45,7 @@ const MIN_REPEAT_TIME = 5 * MINUTES;
|
|||
const MAX_REPEAT_TIME = Math.pow(2, 32);
|
||||
const MAX_REPEAT_UNTIL = moment().add(100, "years");
|
||||
|
||||
export class PostPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||
export class PostPlugin extends ZeppelinPluginClass<TConfigSchema> {
|
||||
public static pluginName = "post";
|
||||
public static configSchema = ConfigSchema;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import { decorators as d, IPluginOptions, logger } from "knub";
|
|||
import { CustomEmoji, errorMessage, isDiscordRESTError, isSnowflake, noop, sleep } from "../utils";
|
||||
import { GuildReactionRoles } from "../data/GuildReactionRoles";
|
||||
import { Message, TextChannel } from "eris";
|
||||
import { ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { ZeppelinPluginClass } from "./ZeppelinPluginClass";
|
||||
import { GuildSavedMessages } from "../data/GuildSavedMessages";
|
||||
import { Queue } from "../Queue";
|
||||
import { ReactionRole } from "../data/entities/ReactionRole";
|
||||
|
@ -42,7 +42,7 @@ type PendingMemberRoleChanges = {
|
|||
}>;
|
||||
};
|
||||
|
||||
export class ReactionRolesPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||
export class ReactionRolesPlugin extends ZeppelinPluginClass<TConfigSchema> {
|
||||
public static pluginName = "reaction_roles";
|
||||
public static configSchema = ConfigSchema;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { decorators as d, IPluginOptions } from "knub";
|
||||
import { ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { ZeppelinPluginClass } from "./ZeppelinPluginClass";
|
||||
import { GuildReminders } from "../data/GuildReminders";
|
||||
import { Message, TextChannel } from "eris";
|
||||
import moment from "moment-timezone";
|
||||
|
@ -22,7 +22,7 @@ type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
|||
const REMINDER_LOOP_TIME = 10 * 1000;
|
||||
const MAX_TRIES = 3;
|
||||
|
||||
export class RemindersPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||
export class RemindersPlugin extends ZeppelinPluginClass<TConfigSchema> {
|
||||
public static pluginName = "reminders";
|
||||
public static configSchema = ConfigSchema;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { trimPluginDescription, ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { trimPluginDescription, ZeppelinPluginClass } from "./ZeppelinPluginClass";
|
||||
import * as t from "io-ts";
|
||||
import { resolveMember, stripObjectToScalars, successMessage } from "../utils";
|
||||
import { decorators as d, IPluginOptions, logger } from "knub";
|
||||
|
@ -13,7 +13,7 @@ const ConfigSchema = t.type({
|
|||
});
|
||||
type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
||||
|
||||
export class RolesPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||
export class RolesPlugin extends ZeppelinPluginClass<TConfigSchema> {
|
||||
public static pluginName = "roles";
|
||||
public static configSchema = ConfigSchema;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { decorators as d, IPluginOptions } from "knub";
|
||||
import { GuildChannel, Message, Role, TextChannel } from "eris";
|
||||
import { asSingleLine, chunkArray, errorMessage, sorter, successMessage, tDeepPartial, trimLines } from "../utils";
|
||||
import { trimPluginDescription, ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { trimPluginDescription, ZeppelinPluginClass } from "./ZeppelinPluginClass";
|
||||
import * as t from "io-ts";
|
||||
|
||||
const RoleMap = t.record(t.string, t.array(t.string));
|
||||
|
@ -29,7 +29,7 @@ const defaultSelfGrantableRoleEntry: t.TypeOf<typeof PartialRoleEntry> = {
|
|||
max_roles: 0,
|
||||
};
|
||||
|
||||
export class SelfGrantableRolesPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||
export class SelfGrantableRolesPlugin extends ZeppelinPluginClass<TConfigSchema> {
|
||||
public static pluginName = "self_grantable_roles";
|
||||
public static showInDocs = true;
|
||||
public static configSchema = ConfigSchema;
|
||||
|
|
|
@ -12,7 +12,7 @@ import {
|
|||
} from "../utils";
|
||||
import { GuildSlowmodes } from "../data/GuildSlowmodes";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { ZeppelinPluginClass } from "./ZeppelinPluginClass";
|
||||
import { SavedMessage } from "../data/entities/SavedMessage";
|
||||
import { GuildSavedMessages } from "../data/GuildSavedMessages";
|
||||
import { GuildLogs } from "../data/GuildLogs";
|
||||
|
@ -31,7 +31,7 @@ const NATIVE_SLOWMODE_LIMIT = 6 * 60 * 60; // 6 hours
|
|||
const MAX_SLOWMODE = 60 * 60 * 24 * 365 * 100; // 100 years
|
||||
const BOT_SLOWMODE_CLEAR_INTERVAL = 60 * 1000;
|
||||
|
||||
export class SlowmodePlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||
export class SlowmodePlugin extends ZeppelinPluginClass<TConfigSchema> {
|
||||
public static pluginName = "slowmode";
|
||||
public static configSchema = ConfigSchema;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import moment from "moment-timezone";
|
|||
import { SavedMessage } from "../data/entities/SavedMessage";
|
||||
import { GuildSavedMessages } from "../data/GuildSavedMessages";
|
||||
import { GuildMutes } from "../data/GuildMutes";
|
||||
import { trimPluginDescription, ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { trimPluginDescription, ZeppelinPluginClass } from "./ZeppelinPluginClass";
|
||||
import { MuteResult, MutesPlugin } from "./Mutes";
|
||||
import { CasesPlugin } from "./Cases";
|
||||
import * as t from "io-ts";
|
||||
|
@ -72,7 +72,7 @@ const MAX_INTERVAL = 300;
|
|||
|
||||
const SPAM_ARCHIVE_EXPIRY_DAYS = 90;
|
||||
|
||||
export class SpamPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||
export class SpamPlugin extends ZeppelinPluginClass<TConfigSchema> {
|
||||
public static pluginName = "spam";
|
||||
public static configSchema = ConfigSchema;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { decorators as d, IPluginOptions } from "knub";
|
||||
import { ZeppelinPlugin, trimPluginDescription } from "./ZeppelinPlugin";
|
||||
import { ZeppelinPluginClass, trimPluginDescription } from "./ZeppelinPluginClass";
|
||||
import { Embed, EmbedBase, GuildChannel, Message, TextChannel } from "eris";
|
||||
import {
|
||||
errorMessage,
|
||||
|
@ -43,7 +43,7 @@ const defaultStarboardOpts: Partial<TStarboardOpts> = {
|
|||
enabled: true,
|
||||
};
|
||||
|
||||
export class StarboardPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||
export class StarboardPlugin extends ZeppelinPluginClass<TConfigSchema> {
|
||||
public static pluginName = "starboard";
|
||||
public static configSchema = ConfigSchema;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { ZeppelinPluginClass } from "./ZeppelinPluginClass";
|
||||
import * as t from "io-ts";
|
||||
import { convertDelayStringToMS, DAYS, HOURS, tAlphanumeric, tDateTime, tDeepPartial, tDelayString } from "../utils";
|
||||
import { IPluginOptions } from "knub";
|
||||
|
@ -60,7 +60,7 @@ const DEFAULT_RETENTION_PERIOD = "4w";
|
|||
//endregion
|
||||
//region PLUGIN
|
||||
|
||||
export class StatsPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||
export class StatsPlugin extends ZeppelinPluginClass<TConfigSchema> {
|
||||
public static pluginName = "stats";
|
||||
public static configSchema = tConfigSchema;
|
||||
public static showInDocs = false;
|
||||
|
|
|
@ -15,7 +15,7 @@ import { GuildSavedMessages } from "../data/GuildSavedMessages";
|
|||
import { SavedMessage } from "../data/entities/SavedMessage";
|
||||
import moment from "moment-timezone";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { ZeppelinPluginClass } from "./ZeppelinPluginClass";
|
||||
import { parseTemplate, renderTemplate, TemplateParseError } from "../templateFormatter";
|
||||
import { GuildArchives } from "../data/GuildArchives";
|
||||
import * as t from "io-ts";
|
||||
|
@ -58,7 +58,7 @@ const ConfigSchema = t.type({
|
|||
});
|
||||
type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
||||
|
||||
export class TagsPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||
export class TagsPlugin extends ZeppelinPluginClass<TConfigSchema> {
|
||||
public static pluginName = "tags";
|
||||
public static configSchema = ConfigSchema;
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ import { CaseTypes } from "../data/CaseTypes";
|
|||
import { SavedMessage } from "../data/entities/SavedMessage";
|
||||
import { GuildSavedMessages } from "../data/GuildSavedMessages";
|
||||
import { GuildArchives } from "../data/GuildArchives";
|
||||
import { CommandInfo, trimPluginDescription, ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { CommandInfo, trimPluginDescription, ZeppelinPluginClass } from "./ZeppelinPluginClass";
|
||||
import { getCurrentUptime } from "../uptime";
|
||||
import LCL from "last-commit-log";
|
||||
import * as t from "io-ts";
|
||||
|
@ -125,7 +125,7 @@ type MemberSearchParams = {
|
|||
|
||||
class SearchError extends Error {}
|
||||
|
||||
export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||
export class UtilityPlugin extends ZeppelinPluginClass<TConfigSchema> {
|
||||
public static pluginName = "utility";
|
||||
public static configSchema = ConfigSchema;
|
||||
|
||||
|
@ -1377,13 +1377,13 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
|
|||
const searchStr = args.command.toLowerCase();
|
||||
|
||||
const matchingCommands: Array<{
|
||||
plugin: ZeppelinPlugin;
|
||||
plugin: ZeppelinPluginClass;
|
||||
command: ICommandDefinition<ICommandContext, ICommandExtraData>;
|
||||
}> = [];
|
||||
|
||||
const guildData = this.knub.getGuildData(this.guildId);
|
||||
for (const plugin of guildData.loadedPlugins.values()) {
|
||||
if (!(plugin instanceof ZeppelinPlugin)) continue;
|
||||
if (!(plugin instanceof ZeppelinPluginClass)) continue;
|
||||
|
||||
const registeredCommands = plugin.getRegisteredCommands();
|
||||
for (const registeredCommand of registeredCommands) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { ZeppelinPluginClass } from "./ZeppelinPluginClass";
|
||||
import { decorators as d, IPluginOptions } from "knub";
|
||||
import { Member, TextChannel } from "eris";
|
||||
import { renderTemplate } from "../templateFormatter";
|
||||
|
@ -14,7 +14,7 @@ const ConfigSchema = t.type({
|
|||
});
|
||||
type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
||||
|
||||
export class WelcomeMessagePlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||
export class WelcomeMessagePlugin extends ZeppelinPluginClass<TConfigSchema> {
|
||||
public static pluginName = "welcome_message";
|
||||
public static configSchema = ConfigSchema;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { configUtils, IBasePluginConfig, IPluginOptions, logger, Plugin } from "knub";
|
||||
import { BasePluginType, configUtils, logger, PluginClass, PluginOptions, BasePluginConfig } from "knub";
|
||||
import * as t from "io-ts";
|
||||
import {
|
||||
deepKeyIntersect,
|
||||
|
@ -59,10 +59,7 @@ export function trimPluginDescription(str) {
|
|||
|
||||
const inviteCache = new SimpleCache<Promise<Invite>>(10 * MINUTES, 200);
|
||||
|
||||
export class ZeppelinPlugin<
|
||||
TConfig extends {} = IBasePluginConfig,
|
||||
TCustomOverrideCriteria extends {} = {}
|
||||
> extends Plugin<TConfig, TCustomOverrideCriteria> {
|
||||
export class ZeppelinPluginClass<TPluginType extends BasePluginType = BasePluginType> extends PluginClass<TPluginType> {
|
||||
public static pluginInfo: PluginInfo;
|
||||
public static showInDocs: boolean = true;
|
||||
|
||||
|
@ -76,7 +73,7 @@ export class ZeppelinPlugin<
|
|||
}
|
||||
|
||||
protected canActOn(member1: Member, member2: Member, allowSameLevel = false) {
|
||||
if (member2.id === this.bot.user.id) {
|
||||
if (member2.id === this.client.user.id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -98,11 +95,8 @@ export class ZeppelinPlugin<
|
|||
/**
|
||||
* Wrapper to fetch the real default options from getStaticDefaultOptions()
|
||||
*/
|
||||
protected getDefaultOptions(): IPluginOptions<TConfig, TCustomOverrideCriteria> {
|
||||
return (this.constructor as typeof ZeppelinPlugin).getStaticDefaultOptions() as IPluginOptions<
|
||||
TConfig,
|
||||
TCustomOverrideCriteria
|
||||
>;
|
||||
protected getDefaultOptions(): PluginOptions<TPluginType> {
|
||||
return (this.constructor as typeof ZeppelinPluginClass).getStaticDefaultOptions() as PluginOptions<TPluginType>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -123,7 +117,7 @@ export class ZeppelinPlugin<
|
|||
* Like getStaticDefaultOptions(), we also want to use this function for type checking without creating an instance of
|
||||
* the plugin, which is why this has to be a static function.
|
||||
*/
|
||||
protected static mergeAndDecodeStaticOptions(options: any): IPluginOptions {
|
||||
protected static mergeAndDecodeStaticOptions(options: any): PluginOptions<any> {
|
||||
const defaultOptions: any = this.getStaticDefaultOptions();
|
||||
let mergedConfig = configUtils.mergeConfig({}, defaultOptions.config || {}, options.config || {});
|
||||
const mergedOverrides = options.replaceDefaultOverrides
|
||||
|
@ -168,14 +162,13 @@ export class ZeppelinPlugin<
|
|||
/**
|
||||
* Wrapper that calls mergeAndValidateStaticOptions()
|
||||
*/
|
||||
protected getMergedOptions(): IPluginOptions<TConfig, TCustomOverrideCriteria> {
|
||||
protected getMergedOptions(): PluginOptions<TPluginType> {
|
||||
if (!this.mergedPluginOptions) {
|
||||
this.mergedPluginOptions = ((this.constructor as unknown) as typeof ZeppelinPlugin).mergeAndDecodeStaticOptions(
|
||||
this.pluginOptions,
|
||||
);
|
||||
this.mergedPluginOptions = ((this
|
||||
.constructor as unknown) as typeof ZeppelinPluginClass).mergeAndDecodeStaticOptions(this.pluginOptions);
|
||||
}
|
||||
|
||||
return this.mergedPluginOptions as IPluginOptions<TConfig, TCustomOverrideCriteria>;
|
||||
return this.mergedPluginOptions as PluginOptions<TPluginType>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -208,7 +201,7 @@ export class ZeppelinPlugin<
|
|||
if (isUnicodeEmoji(snowflake)) {
|
||||
return true;
|
||||
} else if (isSnowflake(snowflake)) {
|
||||
for (const guild of this.bot.guilds.values()) {
|
||||
for (const guild of this.client.guilds.values()) {
|
||||
if (guild.emojis.some(e => (e as any).id === snowflake)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -226,8 +219,8 @@ export class ZeppelinPlugin<
|
|||
}
|
||||
|
||||
getUser(userResolvable: string): User | UnknownUser {
|
||||
const id = resolveUserId(this.bot, userResolvable);
|
||||
return id ? this.bot.users.get(id) || new UnknownUser({ id }) : new UnknownUser();
|
||||
const id = resolveUserId(this.client, userResolvable);
|
||||
return id ? this.client.users.get(id) || new UnknownUser({ id }) : new UnknownUser();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -238,7 +231,7 @@ export class ZeppelinPlugin<
|
|||
async resolveUser<T>(userResolvable: Not<T, string>): Promise<UnknownUser>;
|
||||
async resolveUser(userResolvable) {
|
||||
const start = performance.now();
|
||||
const user = await resolveUser(this.bot, userResolvable);
|
||||
const user = await resolveUser(this.client, userResolvable);
|
||||
const time = performance.now() - start;
|
||||
if (time >= SLOW_RESOLVE_THRESHOLD) {
|
||||
const rounded = Math.round(time);
|
||||
|
@ -253,7 +246,7 @@ export class ZeppelinPlugin<
|
|||
* @param roleResolvable
|
||||
*/
|
||||
async resolveRoleId(roleResolvable: string): Promise<string | null> {
|
||||
const roleId = await resolveRoleId(this.bot, this.guildId, roleResolvable);
|
||||
const roleId = await resolveRoleId(this.client, this.guildId, roleResolvable);
|
||||
return roleId;
|
||||
}
|
||||
|
||||
|
@ -266,9 +259,9 @@ export class ZeppelinPlugin<
|
|||
|
||||
let member;
|
||||
if (forceFresh) {
|
||||
const userId = await resolveUserId(this.bot, memberResolvable);
|
||||
const userId = await resolveUserId(this.client, memberResolvable);
|
||||
try {
|
||||
member = userId && (await this.bot.getRESTGuildMember(this.guild.id, userId));
|
||||
member = userId && (await this.client.getRESTGuildMember(this.guild.id, userId));
|
||||
} catch (e) {
|
||||
if (!isDiscordRESTError(e)) {
|
||||
throw e;
|
||||
|
@ -277,7 +270,7 @@ export class ZeppelinPlugin<
|
|||
|
||||
if (member) member.id = member.user.id;
|
||||
} else {
|
||||
member = await resolveMember(this.bot, this.guild, memberResolvable);
|
||||
member = await resolveMember(this.client, this.guild, memberResolvable);
|
||||
}
|
||||
|
||||
const time = performance.now() - start;
|
||||
|
@ -294,7 +287,7 @@ export class ZeppelinPlugin<
|
|||
return inviteCache.get(code);
|
||||
}
|
||||
|
||||
const promise = this.bot.getInvite(code).catch(() => null);
|
||||
const promise = this.client.getInvite(code).catch(() => null);
|
||||
inviteCache.set(code, promise);
|
||||
|
||||
return promise;
|
|
@ -1,11 +1,11 @@
|
|||
import { IGlobalConfig, IGuildConfig, Knub } from "knub";
|
||||
import { BaseConfig, Knub } from "knub";
|
||||
|
||||
export interface IZeppelinGuildConfig extends IGuildConfig {
|
||||
export interface IZeppelinGuildConfig extends BaseConfig<any> {
|
||||
success_emoji?: string;
|
||||
error_emoji?: string;
|
||||
}
|
||||
|
||||
export interface IZeppelinGlobalConfig extends IGlobalConfig {
|
||||
export interface IZeppelinGlobalConfig extends BaseConfig<any> {
|
||||
url: string;
|
||||
owners?: string[];
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue