3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

Update to Knub 24. Update Node typings to fix error with [util.inspect.custom] property.

This commit is contained in:
Dragory 2019-09-22 17:06:22 +03:00
parent 1681a45069
commit 4d7ab10fcf
12 changed files with 183 additions and 122 deletions

67
package-lock.json generated
View file

@ -2560,9 +2560,9 @@
} }
}, },
"@types/node": { "@types/node": {
"version": "10.12.0", "version": "12.7.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.0.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.5.tgz",
"integrity": "sha512-3TUHC3jsBAB7qVRGxT6lWyYo2v96BMmD2PTcl47H25Lu7UXtFH/2qqmKiVrnel6Ne//0TFYf6uvNX+HW2FRkLQ==" "integrity": "sha512-9fq4jZVhPNW8r+UYKnxF1e2HkDWOWKM5bC2/7c9wPV835I0aOrVbS/Hw/pWPk2uKrNXQqg9Z959Kz+IYDd5p3w=="
}, },
"@types/oauth": { "@types/oauth": {
"version": "0.9.1", "version": "0.9.1",
@ -8299,16 +8299,49 @@
"dev": true "dev": true
}, },
"knub": { "knub": {
"version": "22.0.0", "version": "24.0.0",
"resolved": "https://registry.npmjs.org/knub/-/knub-22.0.0.tgz", "resolved": "https://registry.npmjs.org/knub/-/knub-24.0.0.tgz",
"integrity": "sha512-QHMqSS8eVBVX0vMff8lEkWhO7mOVXdobUrNOuAMI7ldto0Aakf0oNdDnwRXFj0yNb5Sp1fvzYFt35nsx/ORqkw==", "integrity": "sha512-qQimi9L3p1kVV08TI3MeSN8J2CzjrYwGLVpN8IiwBvvbRFPJcVcSzvw3CSTbs594m6Zr8/MnXdh5fDQBGuMI6Q==",
"requires": { "requires": {
"escape-string-regexp": "^1.0.5", "escape-string-regexp": "^2.0.0",
"lodash.at": "^4.6.0", "knub-command-manager": "^5.1.0",
"lodash.difference": "^4.5.0", "reflect-metadata": "^0.1.13",
"lodash.merge": "^4.6.2", "ts-essentials": "^2.0.12"
"reflect-metadata": "^0.1.10", },
"ts-essentials": "^2.0.3" "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": "5.1.0",
"resolved": "https://registry.npmjs.org/knub-command-manager/-/knub-command-manager-5.1.0.tgz",
"integrity": "sha512-zxYwglsdAVbskoU0WYc6nB9+nJVYQIhwLz0olvQyYprV0EIU0Wo7QDeAHbcEQUMDZEmJ1jfVAEzGGwvSHItIpA==",
"requires": {
"escape-string-regexp": "^2.0.0"
}
},
"reflect-metadata": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz",
"integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg=="
}
}
},
"knub-command-manager": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/knub-command-manager/-/knub-command-manager-5.1.0.tgz",
"integrity": "sha512-zxYwglsdAVbskoU0WYc6nB9+nJVYQIhwLz0olvQyYprV0EIU0Wo7QDeAHbcEQUMDZEmJ1jfVAEzGGwvSHItIpA==",
"requires": {
"escape-string-regexp": "^2.0.0"
},
"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=="
}
} }
}, },
"last-commit-log": { "last-commit-log": {
@ -8561,11 +8594,6 @@
"integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==",
"dev": true "dev": true
}, },
"lodash.at": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/lodash.at/-/lodash.at-4.6.0.tgz",
"integrity": "sha1-k83OZk8KGZTqM9181A4jr9EbD/g="
},
"lodash.chunk": { "lodash.chunk": {
"version": "4.2.0", "version": "4.2.0",
"resolved": "https://registry.npmjs.org/lodash.chunk/-/lodash.chunk-4.2.0.tgz", "resolved": "https://registry.npmjs.org/lodash.chunk/-/lodash.chunk-4.2.0.tgz",
@ -8597,11 +8625,6 @@
"resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz",
"integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA=" "integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA="
}, },
"lodash.merge": {
"version": "4.6.2",
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
"integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ=="
},
"lodash.pick": { "lodash.pick": {
"version": "4.4.0", "version": "4.4.0",
"resolved": "https://registry.npmjs.org/lodash.pick/-/lodash.pick-4.4.0.tgz", "resolved": "https://registry.npmjs.org/lodash.pick/-/lodash.pick-4.4.0.tgz",

View file

@ -30,7 +30,8 @@
"humanize-duration": "^3.15.0", "humanize-duration": "^3.15.0",
"io-ts": "^2.0.0", "io-ts": "^2.0.0",
"js-yaml": "^3.13.1", "js-yaml": "^3.13.1",
"knub": "^22.0.0", "knub": "^24.0.0",
"knub-command-manager": "^5.1.0",
"last-commit-log": "^2.1.0", "last-commit-log": "^2.1.0",
"lodash.chunk": "^4.2.0", "lodash.chunk": "^4.2.0",
"lodash.clonedeep": "^4.5.0", "lodash.clonedeep": "^4.5.0",
@ -63,7 +64,7 @@
"@types/js-yaml": "^3.12.1", "@types/js-yaml": "^3.12.1",
"@types/lodash.at": "^4.6.3", "@types/lodash.at": "^4.6.3",
"@types/moment-timezone": "^0.5.6", "@types/moment-timezone": "^0.5.6",
"@types/node": "^10.12.0", "@types/node": "^12.7.5",
"@types/passport": "^1.0.0", "@types/passport": "^1.0.0",
"@types/passport-oauth2": "^1.4.8", "@types/passport-oauth2": "^1.4.8",
"@types/tmp": "0.0.33", "@types/tmp": "0.0.33",

View file

@ -11,7 +11,7 @@ export class PluginRuntimeError {
this.guildId = guildId; this.guildId = guildId;
} }
[util.inspect.custom](depth, options) { [util.inspect.custom](depth?, options?) {
return `PRE [${this.pluginName}] [${this.guildId}] ${this.message}`; return `PRE [${this.pluginName}] [${this.guildId}] ${this.message}`;
} }

View file

@ -2,10 +2,9 @@ import express from "express";
import { availablePlugins } from "../plugins/availablePlugins"; import { availablePlugins } from "../plugins/availablePlugins";
import { ZeppelinPlugin } from "../plugins/ZeppelinPlugin"; import { ZeppelinPlugin } from "../plugins/ZeppelinPlugin";
import { notFound } from "./responses"; import { notFound } from "./responses";
import { CommandManager, ICommandConfig } from "knub/dist/CommandManager";
import { dropPropertiesByName, indentLines } from "../utils"; import { dropPropertiesByName, indentLines } from "../utils";
import { IPluginCommandConfig, Plugin, pluginUtils } from "knub";
const commandManager = new CommandManager(); import { parseParameters } from "knub-command-manager";
function formatConfigSchema(schema) { function formatConfigSchema(schema) {
if (schema._tag === "InterfaceType" || schema._tag === "PartialType") { if (schema._tag === "InterfaceType" || schema._tag === "PartialType") {
@ -79,20 +78,20 @@ export function initDocs(app: express.Express) {
const props = Reflect.ownKeys(pluginClass.prototype); const props = Reflect.ownKeys(pluginClass.prototype);
const commands = props.reduce((arr, prop) => { const commands = props.reduce((arr, prop) => {
if (typeof prop !== "string") return arr; if (typeof prop !== "string") return arr;
const propCommands = Reflect.getMetadata("commands", pluginClass.prototype, prop); const decoratorCommands = pluginUtils.getPluginDecoratorCommands(pluginClass as typeof Plugin);
if (propCommands) { if (decoratorCommands) {
arr.push( arr.push(
...propCommands.map(cmd => { ...decoratorCommands.map(cmd => {
const trigger = typeof cmd.command === "string" ? cmd.command : cmd.command.source; const trigger = typeof cmd.trigger === "string" ? cmd.trigger : cmd.trigger.source;
const parameters = cmd.parameters const parameters = cmd.parameters
? typeof cmd.parameters === "string" ? typeof cmd.parameters === "string"
? commandManager.parseParameterString(cmd.parameters) ? parseParameters(cmd.parameters)
: cmd.parameters : cmd.parameters
: []; : [];
const config: ICommandConfig = cmd.options || {}; const config: IPluginCommandConfig = cmd.config || {};
if (config.overloads) { if (config.overloads) {
config.overloads = config.overloads.map(overload => { config.overloads = config.overloads.map(overload => {
return typeof overload === "string" ? commandManager.parseParameterString(overload) : overload; return typeof overload === "string" ? parseParameters(overload) : overload;
}); });
} }

View file

@ -6,41 +6,42 @@ import {
resolveUser, resolveUser,
UnknownUser, UnknownUser,
} from "./utils"; } from "./utils";
import { CommandArgumentTypeError } from "knub";
import { Client, GuildChannel, Message } from "eris"; import { Client, GuildChannel, Message } from "eris";
import { TypeConversionError } from "knub-command-manager";
import { ICommandContext } from "knub";
export const customArgumentTypes = { export const customArgumentTypes = {
delay(value) { delay(value) {
const result = convertDelayStringToMS(value); const result = convertDelayStringToMS(value);
if (result == null) { if (result == null) {
throw new CommandArgumentTypeError(`Could not convert ${value} to a delay`); throw new TypeConversionError(`Could not convert ${value} to a delay`);
} }
return result; return result;
}, },
async resolvedUser(value, msg, bot: Client) { async resolvedUser(value, context: ICommandContext) {
const result = await resolveUser(bot, value); const result = await resolveUser(context.bot, value);
if (result == null || result instanceof UnknownUser) { if (result == null || result instanceof UnknownUser) {
throw new CommandArgumentTypeError(`User \`${disableCodeBlocks(value)}\` was not found`); throw new TypeConversionError(`User \`${disableCodeBlocks(value)}\` was not found`);
} }
return result; return result;
}, },
async resolvedUserLoose(value, msg, bot: Client) { async resolvedUserLoose(value, context: ICommandContext) {
const result = await resolveUser(bot, value); const result = await resolveUser(context.bot, value);
if (result == null) { if (result == null) {
throw new CommandArgumentTypeError(`Invalid user: \`${disableCodeBlocks(value)}\``); throw new TypeConversionError(`Invalid user: \`${disableCodeBlocks(value)}\``);
} }
return result; return result;
}, },
async resolvedMember(value, msg: Message, bot: Client) { async resolvedMember(value, context: ICommandContext) {
if (!(msg.channel instanceof GuildChannel)) return null; if (!(context.message.channel instanceof GuildChannel)) return null;
const result = await resolveMember(bot, msg.channel.guild, value); const result = await resolveMember(context.bot, context.message.channel.guild, value);
if (result == null) { if (result == null) {
throw new CommandArgumentTypeError( throw new TypeConversionError(
`Member \`${disableCodeBlocks(value)}\` was not found or they have left the server`, `Member \`${disableCodeBlocks(value)}\` was not found or they have left the server`,
); );
} }

View file

@ -1,4 +1,4 @@
import { decorators as d, logger } from "knub"; import { decorators as d, ICommandContext, logger } from "knub";
import { GlobalZeppelinPlugin } from "./GlobalZeppelinPlugin"; import { GlobalZeppelinPlugin } from "./GlobalZeppelinPlugin";
import { Attachment, GuildChannel, Message, TextChannel } from "eris"; import { Attachment, GuildChannel, Message, TextChannel } from "eris";
import { confirm, downloadFile, errorMessage, noop, SECONDS, trimLines } from "../utils"; import { confirm, downloadFile, errorMessage, noop, SECONDS, trimLines } from "../utils";
@ -57,8 +57,8 @@ export class ChannelArchiverPlugin extends ZeppelinPlugin {
}, },
], ],
preFilters: [ preFilters: [
(msg, command, plugin: ChannelArchiverPlugin) => { (command, context: ICommandContext) => {
return plugin.isOwner(msg.author.id); return (context.plugin as ChannelArchiverPlugin).isOwner(context.message.author.id);
}, },
], ],
}) })

View file

@ -87,7 +87,7 @@ export class CustomEventsPlugin extends ZeppelinPlugin<TConfigSchema> {
onLoad() { onLoad() {
for (const [key, event] of Object.entries(this.getConfig().events)) { for (const [key, event] of Object.entries(this.getConfig().events)) {
if (event.trigger.type === "command") { if (event.trigger.type === "command") {
this.commands.add( this.addCommand(
event.trigger.name, event.trigger.name,
event.trigger.params, event.trigger.params,
(msg, args) => { (msg, args) => {
@ -95,8 +95,9 @@ export class CustomEventsPlugin extends ZeppelinPlugin<TConfigSchema> {
this.runEvent(event, { msg, args }, { args, msg: strippedMsg }); this.runEvent(event, { msg, args }, { args, msg: strippedMsg });
}, },
{ {
requiredPermission: `events.${key}.trigger.can_use`, extra: {
locks: [], requiredPermission: `events.${key}.trigger.can_use`,
},
}, },
); );
} }

View file

@ -78,8 +78,10 @@ export class LocatePlugin extends ZeppelinPlugin<TConfigSchema> {
} }
@d.command("where", "<member:resolvedMember>", { @d.command("where", "<member:resolvedMember>", {
info: { extra: {
description: "Posts an instant invite to the voice channel that `<member>` is in", info: {
description: "Posts an instant invite to the voice channel that `<member>` is in",
},
}, },
}) })
@d.permission("can_where") @d.permission("can_where")
@ -90,8 +92,10 @@ export class LocatePlugin extends ZeppelinPlugin<TConfigSchema> {
@d.command("vcalert", "<member:resolvedMember> [duration:delay] [reminder:string$]", { @d.command("vcalert", "<member:resolvedMember> [duration:delay] [reminder:string$]", {
aliases: ["vca"], aliases: ["vca"],
info: { extra: {
description: "Sets up an alert that notifies you any time `<member>` switches or joins voice channels", info: {
description: "Sets up an alert that notifies you any time `<member>` switches or joins voice channels",
},
}, },
}) })
@d.permission("can_alert") @d.permission("can_alert")

View file

@ -483,9 +483,11 @@ export class ModActionsPlugin extends ZeppelinPlugin<TConfigSchema> {
@d.command("update", "<caseNumber:number> [note:string$]", { @d.command("update", "<caseNumber:number> [note:string$]", {
overloads: ["[note:string$]"], overloads: ["[note:string$]"],
info: { extra: {
description: info: {
"Update the specified case (or, if case number is omitted, your latest case) by adding more notes/details to it", description:
"Update the specified case (or, if case number is omitted, your latest case) by adding more notes/details to it",
},
}, },
}) })
@d.permission("can_note") @d.permission("can_note")
@ -527,8 +529,10 @@ export class ModActionsPlugin extends ZeppelinPlugin<TConfigSchema> {
} }
@d.command("note", "<user:string> <note:string$>", { @d.command("note", "<user:string> <note:string$>", {
info: { extra: {
description: "Add a note to the specified user", info: {
description: "Add a note to the specified user",
},
}, },
}) })
@d.permission("can_note") @d.permission("can_note")
@ -552,8 +556,10 @@ export class ModActionsPlugin extends ZeppelinPlugin<TConfigSchema> {
@d.command("warn", "<user:string> <reason:string$>", { @d.command("warn", "<user:string> <reason:string$>", {
options: [{ name: "mod", type: "member" }], options: [{ name: "mod", type: "member" }],
info: { extra: {
description: "Send a warning to the specified user", info: {
description: "Send a warning to the specified user",
},
}, },
}) })
@d.permission("can_warn") @d.permission("can_warn")
@ -757,8 +763,10 @@ export class ModActionsPlugin extends ZeppelinPlugin<TConfigSchema> {
@d.command("mute", "<user:string> <time:delay> <reason:string$>", { @d.command("mute", "<user:string> <time:delay> <reason:string$>", {
overloads: ["<user:string> <time:delay>", "<user:string> [reason:string$]"], overloads: ["<user:string> <time:delay>", "<user:string> [reason:string$]"],
options: [{ name: "mod", type: "member" }], options: [{ name: "mod", type: "member" }],
info: { extra: {
description: "Mute the specified member", info: {
description: "Mute the specified member",
},
}, },
}) })
@d.permission("can_mute") @d.permission("can_mute")
@ -798,8 +806,10 @@ export class ModActionsPlugin extends ZeppelinPlugin<TConfigSchema> {
@d.command("forcemute", "<user:string> <time:delay> <reason:string$>", { @d.command("forcemute", "<user:string> <time:delay> <reason:string$>", {
overloads: ["<user:string> <time:delay>", "<user:string> [reason:string$]"], overloads: ["<user:string> <time:delay>", "<user:string> [reason:string$]"],
options: [{ name: "mod", type: "member" }], options: [{ name: "mod", type: "member" }],
info: { extra: {
description: "Force-mute the specified user, even if they're not on the server", info: {
description: "Force-mute the specified user, even if they're not on the server",
},
}, },
}) })
@d.permission("can_mute") @d.permission("can_mute")
@ -876,8 +886,10 @@ export class ModActionsPlugin extends ZeppelinPlugin<TConfigSchema> {
@d.command("unmute", "<user:string> <time:delay> <reason:string$>", { @d.command("unmute", "<user:string> <time:delay> <reason:string$>", {
overloads: ["<user:string> <time:delay>", "<user:string> [reason:string$]"], overloads: ["<user:string> <time:delay>", "<user:string> [reason:string$]"],
options: [{ name: "mod", type: "member" }], options: [{ name: "mod", type: "member" }],
info: { extra: {
description: "Unmute the specified member", info: {
description: "Unmute the specified member",
},
}, },
}) })
@d.permission("can_mute") @d.permission("can_mute")
@ -921,8 +933,10 @@ export class ModActionsPlugin extends ZeppelinPlugin<TConfigSchema> {
@d.command("forceunmute", "<user:string> <time:delay> <reason:string$>", { @d.command("forceunmute", "<user:string> <time:delay> <reason:string$>", {
overloads: ["<user:string> <time:delay>", "<user:string> [reason:string$]"], overloads: ["<user:string> <time:delay>", "<user:string> [reason:string$]"],
options: [{ name: "mod", type: "member" }], options: [{ name: "mod", type: "member" }],
info: { extra: {
description: "Force-unmute the specified user, even if they're not on the server", info: {
description: "Force-unmute the specified user, even if they're not on the server",
},
}, },
}) })
@d.permission("can_mute") @d.permission("can_mute")
@ -950,8 +964,10 @@ export class ModActionsPlugin extends ZeppelinPlugin<TConfigSchema> {
@d.command("kick", "<user:string> [reason:string$]", { @d.command("kick", "<user:string> [reason:string$]", {
options: [{ name: "mod", type: "member" }], options: [{ name: "mod", type: "member" }],
info: { extra: {
description: "Kick the specified member", info: {
description: "Kick the specified member",
},
}, },
}) })
@d.permission("can_kick") @d.permission("can_kick")
@ -1011,8 +1027,10 @@ export class ModActionsPlugin extends ZeppelinPlugin<TConfigSchema> {
@d.command("ban", "<user:string> [reason:string$]", { @d.command("ban", "<user:string> [reason:string$]", {
options: [{ name: "mod", type: "member" }], options: [{ name: "mod", type: "member" }],
info: { extra: {
description: "Ban the specified member", info: {
description: "Ban the specified member",
},
}, },
}) })
@d.permission("can_ban") @d.permission("can_ban")
@ -1072,9 +1090,11 @@ export class ModActionsPlugin extends ZeppelinPlugin<TConfigSchema> {
@d.command("softban", "<user:string> [reason:string$]", { @d.command("softban", "<user:string> [reason:string$]", {
options: [{ name: "mod", type: "member" }], options: [{ name: "mod", type: "member" }],
info: { extra: {
description: info: {
'"Softban" the specified user by banning and immediately unbanning them. Effectively a kick with message deletions.', description:
'"Softban" the specified user by banning and immediately unbanning them. Effectively a kick with message deletions.',
},
}, },
}) })
@d.permission("can_ban") @d.permission("can_ban")
@ -1162,8 +1182,10 @@ export class ModActionsPlugin extends ZeppelinPlugin<TConfigSchema> {
@d.command("unban", "<user:string> [reason:string$]", { @d.command("unban", "<user:string> [reason:string$]", {
options: [{ name: "mod", type: "member" }], options: [{ name: "mod", type: "member" }],
info: { extra: {
description: "Unban the specified member", info: {
description: "Unban the specified member",
},
}, },
}) })
@d.permission("can_ban") @d.permission("can_ban")
@ -1216,8 +1238,10 @@ export class ModActionsPlugin extends ZeppelinPlugin<TConfigSchema> {
@d.command("forceban", "<user:string> [reason:string$]", { @d.command("forceban", "<user:string> [reason:string$]", {
options: [{ name: "mod", type: "member" }], options: [{ name: "mod", type: "member" }],
info: { extra: {
description: "Force-ban the specified user, even if they aren't on the server", info: {
description: "Force-ban the specified user, even if they aren't on the server",
},
}, },
}) })
@d.permission("can_ban") @d.permission("can_ban")
@ -1283,8 +1307,10 @@ export class ModActionsPlugin extends ZeppelinPlugin<TConfigSchema> {
} }
@d.command("massban", "<userIds:string...>", { @d.command("massban", "<userIds:string...>", {
info: { extra: {
description: "Mass-ban a list of user IDs", info: {
description: "Mass-ban a list of user IDs",
},
}, },
}) })
@d.permission("can_massban") @d.permission("can_massban")
@ -1370,8 +1396,10 @@ export class ModActionsPlugin extends ZeppelinPlugin<TConfigSchema> {
@d.command("addcase", "<type:string> <user:string> [reason:string$]", { @d.command("addcase", "<type:string> <user:string> [reason:string$]", {
options: [{ name: "mod", type: "member" }], options: [{ name: "mod", type: "member" }],
info: { extra: {
description: "Add an arbitrary case to the specified user without taking any action", info: {
description: "Add an arbitrary case to the specified user without taking any action",
},
}, },
}) })
@d.permission("can_addcase") @d.permission("can_addcase")
@ -1434,8 +1462,10 @@ export class ModActionsPlugin extends ZeppelinPlugin<TConfigSchema> {
} }
@d.command("case", "<caseNumber:number>", { @d.command("case", "<caseNumber:number>", {
info: { extra: {
description: "Show information about a specific case", info: {
description: "Show information about a specific case",
},
}, },
}) })
@d.permission("can_view") @d.permission("can_view")
@ -1465,8 +1495,10 @@ export class ModActionsPlugin extends ZeppelinPlugin<TConfigSchema> {
shortcut: "h", shortcut: "h",
}, },
], ],
info: { extra: {
description: "Show a list of cases the specified user has", info: {
description: "Show a list of cases the specified user has",
},
}, },
}) })
@d.permission("can_view") @d.permission("can_view")
@ -1532,8 +1564,10 @@ export class ModActionsPlugin extends ZeppelinPlugin<TConfigSchema> {
@d.command("cases", null, { @d.command("cases", null, {
options: [{ name: "mod", type: "Member" }], options: [{ name: "mod", type: "Member" }],
info: { extra: {
description: "Show the most recent 5 cases by the specified --mod", info: {
description: "Show the most recent 5 cases by the specified --mod",
},
}, },
}) })
@d.permission("can_view") @d.permission("can_view")
@ -1561,8 +1595,10 @@ export class ModActionsPlugin extends ZeppelinPlugin<TConfigSchema> {
} }
@d.command("hidecase", "<caseNum:number>", { @d.command("hidecase", "<caseNum:number>", {
info: { extra: {
description: "Hide the specified case so it doesn't appear in !cases or !info", info: {
description: "Hide the specified case so it doesn't appear in !cases or !info",
},
}, },
}) })
@d.permission("can_hidecase") @d.permission("can_hidecase")
@ -1580,8 +1616,10 @@ export class ModActionsPlugin extends ZeppelinPlugin<TConfigSchema> {
} }
@d.command("unhidecase", "<caseNum:number>", { @d.command("unhidecase", "<caseNum:number>", {
info: { extra: {
description: "Un-hide the specified case, making it appear in !cases and !info again", info: {
description: "Un-hide the specified case, making it appear in !cases and !info again",
},
}, },
}) })
@d.permission("can_hidecase") @d.permission("can_hidecase")

View file

@ -10,6 +10,7 @@ import { ZeppelinPlugin } from "./ZeppelinPlugin";
import { parseTemplate, renderTemplate, TemplateParseError } from "../templateFormatter"; import { parseTemplate, renderTemplate, TemplateParseError } from "../templateFormatter";
import { GuildArchives } from "../data/GuildArchives"; import { GuildArchives } from "../data/GuildArchives";
import * as t from "io-ts"; import * as t from "io-ts";
import { parseArguments } from "knub-command-manager";
const ConfigSchema = t.type({ const ConfigSchema = t.type({
prefix: t.string, prefix: t.string,
@ -233,7 +234,7 @@ export class TagsPlugin extends ZeppelinPlugin<TConfigSchema> {
// Substitute variables (matched with Knub's argument parser -> supports quotes etc.) // Substitute variables (matched with Knub's argument parser -> supports quotes etc.)
const variableStr = msg.data.content.slice(prefix.length + tagName.length).trim(); const variableStr = msg.data.content.slice(prefix.length + tagName.length).trim();
const tagArgs = this.commands.parseArguments(variableStr).map(v => v.value); const tagArgs = parseArguments(variableStr).map(v => v.value);
// Format the string // Format the string
try { try {

View file

@ -1,4 +1,11 @@
import { decorators as d, getCommandSignature, IPluginOptions, ICommandDefinition, waitForReaction } from "knub"; import {
decorators as d,
getCommandSignature,
ICommandContext,
ICommandExtraData,
IPluginOptions,
waitForReaction,
} from "knub";
import { import {
CategoryChannel, CategoryChannel,
Channel, Channel,
@ -45,6 +52,7 @@ import { ZeppelinPlugin } from "./ZeppelinPlugin";
import { getCurrentUptime } from "../uptime"; import { getCurrentUptime } from "../uptime";
import LCL from "last-commit-log"; import LCL from "last-commit-log";
import * as t from "io-ts"; import * as t from "io-ts";
import { ICommandDefinition } from "knub-command-manager";
const ConfigSchema = t.type({ const ConfigSchema = t.type({
can_roles: t.boolean, can_roles: t.boolean,
@ -959,17 +967,18 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
helpCmd(msg: Message, args: { command: string }) { helpCmd(msg: Message, args: { command: string }) {
const searchStr = args.command.toLowerCase(); const searchStr = args.command.toLowerCase();
const matchingCommands: ICommandDefinition[] = []; const matchingCommands: Array<ICommandDefinition<ICommandContext, ICommandExtraData>> = [];
const guildData = this.knub.getGuildData(this.guildId); const guildData = this.knub.getGuildData(this.guildId);
for (const plugin of guildData.loadedPlugins.values()) { for (const plugin of guildData.loadedPlugins.values()) {
if (!(plugin instanceof ZeppelinPlugin)) continue; if (!(plugin instanceof ZeppelinPlugin)) continue;
const commands = plugin.getRegisteredCommands(); const registeredCommands = plugin.getRegisteredCommands();
for (const command of commands) { for (const registeredCommand of registeredCommands) {
const trigger = command.trigger.source.toLowerCase(); for (const trigger of registeredCommand.command.triggers) {
if (trigger.startsWith(searchStr)) { if (trigger.source.startsWith(searchStr)) {
matchingCommands.push(command); matchingCommands.push(registeredCommand.command);
}
} }
} }
} }
@ -977,16 +986,7 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
const totalResults = matchingCommands.length; const totalResults = matchingCommands.length;
const limitedResults = matchingCommands.slice(0, 15); const limitedResults = matchingCommands.slice(0, 15);
const signatures = limitedResults.map(command => { const signatures = limitedResults.map(command => {
return ( return "`" + getCommandSignature(command) + "`";
"`" +
getCommandSignature(
guildData.config.prefix,
command.trigger.source,
command.parameters,
command.config.options,
) +
"`"
);
}); });
if (totalResults === 0) { if (totalResults === 0) {

View file

@ -184,13 +184,6 @@ export class ZeppelinPlugin<TConfig extends {} = IBasePluginConfig> extends Plug
} }
} }
/**
* Intended for cross-plugin functionality
*/
public getRegisteredCommands() {
return this.commands.commands;
}
/** /**
* Intended for cross-plugin functionality * Intended for cross-plugin functionality
*/ */