From f76dd3ed622bce0ff7a5df564d7788e65c495753 Mon Sep 17 00:00:00 2001 From: Dragory Date: Sat, 13 Apr 2019 04:01:37 +0300 Subject: [PATCH] Deprecate !cases expand/hidden in favor of options --expand/--hidden (-e/-h) --- src/plugins/ModActions.ts | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/src/plugins/ModActions.ts b/src/plugins/ModActions.ts index ebeb9705..b921c673 100644 --- a/src/plugins/ModActions.ts +++ b/src/plugins/ModActions.ts @@ -1099,9 +1099,22 @@ export class ModActionsPlugin extends ZeppelinPlugin { }); } - @d.command("cases", " [opts:string$]") + @d.command("cases", " [opts:string$]", { + options: [ + { + name: "expand", + type: "boolean", + shortcut: "e", + }, + { + name: "hidden", + type: "boolean", + shortcut: "h", + }, + ], + }) @d.permission("can_view") - async userCasesCmd(msg: Message, args: { userId: string; opts?: string }) { + async userCasesCmd(msg: Message, args: { userId: string; opts?: string; expand?: boolean; hidden?: boolean }) { const cases = await this.cases.with("notes").getByUserId(args.userId); const normalCases = cases.filter(c => !c.is_hidden); const hiddenCases = cases.filter(c => c.is_hidden); @@ -1112,10 +1125,10 @@ export class ModActionsPlugin extends ZeppelinPlugin { if (cases.length === 0) { msg.channel.createMessage(`No cases found for ${user ? `**${userName}**` : "the specified user"}`); } else { - const showHidden = args.opts && args.opts.match(/\bhidden\b/); + const showHidden = args.hidden || (args.opts && args.opts.match(/\bhidden\b/)); const casesToDisplay = showHidden ? cases : normalCases; - if (args.opts && args.opts.match(/\b(expand|e)\b/)) { + if (args.expand || (args.opts && args.opts.match(/\b(expand|e)\b/))) { if (casesToDisplay.length > 8) { msg.channel.createMessage("Too many cases for expanded view. Please use compact view instead."); return; @@ -1139,9 +1152,9 @@ export class ModActionsPlugin extends ZeppelinPlugin { if (!showHidden && hiddenCases.length) { 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 { - lines.push(`*+${hiddenCases.length} hidden cases, use "hidden" to show them*`); + lines.push(`*+${hiddenCases.length} hidden cases, use "--hidden" to show them*`); } } @@ -1155,6 +1168,14 @@ export class ModActionsPlugin extends ZeppelinPlugin { 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)`, + ); + } } }