Allow using !update without a case number. Will update the mod's latest case instead.

This commit is contained in:
Dragory 2019-02-17 15:23:40 +02:00
parent ed3760313f
commit fa759d1f46
2 changed files with 47 additions and 13 deletions

View file

@ -261,7 +261,7 @@ export class ModActionsPlugin extends ZeppelinPlugin {
*/
@d.command(/update|updatecase/, "<caseNumber:number> <note:string$>")
@d.permission("note")
async updateCmd(msg: Message, args: any) {
async updateSpecificCmd(msg: Message, args: { caseNumber: number; note: string }) {
const theCase = await this.cases.findByCaseNumber(args.caseNumber);
if (!theCase) {
msg.channel.createMessage(errorMessage("Case not found"));
@ -277,6 +277,27 @@ export class ModActionsPlugin extends ZeppelinPlugin {
msg.channel.createMessage(successMessage(`Case \`#${theCase.case_number}\` updated`));
}
/**
* Update the latest case
*/
@d.command(/update|updatecase/, "<note:string$>")
@d.permission("note")
async updateLatestCmd(msg: Message, args: { note: string }) {
const theCase = await this.cases.findLatestByModId(msg.author.id);
if (!theCase) {
msg.channel.createMessage(errorMessage("No latest case"));
return;
}
await this.actions.fire("createCaseNote", {
caseId: theCase.id,
modId: msg.author.id,
note: args.note,
});
msg.channel.createMessage(successMessage(`Case \`#${theCase.case_number}\` updated`));
}
@d.command("note", "<userId:userId> <note:string$>")
@d.permission("note")
async noteCmd(msg: Message, args: any) {