Remove deprecated expand/hidden opts from !cases, use --expand/--hidden instead

This commit is contained in:
Dragory 2019-05-02 08:28:49 +03:00
parent e259574bcc
commit 2d0f4ead20

View file

@ -1223,7 +1223,7 @@ export class ModActionsPlugin extends ZeppelinPlugin<IModActionsPluginConfig> {
msg.channel.createMessage(embed); msg.channel.createMessage(embed);
} }
@d.command("cases", "<user:string> [opts:string$]", { @d.command("cases", "<user:string>", {
options: [ options: [
{ {
name: "expand", name: "expand",
@ -1238,7 +1238,7 @@ export class ModActionsPlugin extends ZeppelinPlugin<IModActionsPluginConfig> {
], ],
}) })
@d.permission("can_view") @d.permission("can_view")
async userCasesCmd(msg: Message, args: { user: string; opts?: string; expand?: boolean; hidden?: boolean }) { async userCasesCmd(msg: Message, args: { user: string; expand?: boolean; hidden?: boolean }) {
const user = await this.resolveUser(args.user); const user = await this.resolveUser(args.user);
if (!user) return this.sendErrorMessage(msg.channel, `User not found`); if (!user) return this.sendErrorMessage(msg.channel, `User not found`);
@ -1254,10 +1254,9 @@ export class ModActionsPlugin extends ZeppelinPlugin<IModActionsPluginConfig> {
if (cases.length === 0) { if (cases.length === 0) {
msg.channel.createMessage(`No cases found for **${userName}**`); msg.channel.createMessage(`No cases found for **${userName}**`);
} else { } else {
const showHidden = args.hidden || (args.opts && args.opts.match(/\bhidden\b/)); const casesToDisplay = args.hidden ? cases : normalCases;
const casesToDisplay = showHidden ? cases : normalCases;
if (args.expand || (args.opts && args.opts.match(/\b(expand|e)\b/))) { if (args.expand) {
if (casesToDisplay.length > 8) { if (casesToDisplay.length > 8) {
msg.channel.createMessage("Too many cases for expanded view. Please use compact view instead."); msg.channel.createMessage("Too many cases for expanded view. Please use compact view instead.");
return; return;
@ -1278,7 +1277,7 @@ export class ModActionsPlugin extends ZeppelinPlugin<IModActionsPluginConfig> {
lines.push(caseSummary); lines.push(caseSummary);
} }
if (!showHidden && hiddenCases.length) { if (!args.hidden && hiddenCases.length) {
if (hiddenCases.length === 1) { if (hiddenCases.length === 1) {
lines.push(`*+${hiddenCases.length} hidden case, use "--hidden" to show it*`); lines.push(`*+${hiddenCases.length} hidden case, use "--hidden" to show it*`);
} else { } else {
@ -1296,14 +1295,6 @@ export class ModActionsPlugin extends ZeppelinPlugin<IModActionsPluginConfig> {
createChunkedMessage(msg.channel, finalMessage); createChunkedMessage(msg.channel, finalMessage);
} }
if ((args.opts && args.opts.match(/\bhidden\b/)) || (args.opts && args.opts.match(/\b(expand|e)\b/))) {
msg.channel.createMessage(
`<@!${
msg.author.id
}> **Note:** expand/hidden have been replaced with --expand/--hidden (and -e/-h as shortcuts)`,
);
}
} }
} }