mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-16 22:21:51 +00:00
Clean up !update code
This commit is contained in:
parent
f4544f5452
commit
6216989b90
1 changed files with 11 additions and 24 deletions
|
@ -301,35 +301,22 @@ export class ModActionsPlugin extends ZeppelinPlugin<IModActionsPluginConfig> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the specified case by adding more notes/details to it
|
* Update the specified case (or, if case number is omitted, your latest case) by adding more notes/details to it
|
||||||
*/
|
*/
|
||||||
@d.command("update", "<caseNumber:number> <note:string$>")
|
@d.command("update", "<caseNumber:number> <note:string$>", {
|
||||||
|
overloads: ["<note:string$>"],
|
||||||
|
})
|
||||||
@d.permission("can_note")
|
@d.permission("can_note")
|
||||||
async updateSpecificCmd(msg: Message, args: { caseNumber: number; note: string }) {
|
async updateSpecificCmd(msg: Message, args: { caseNumber?: number; note: string }) {
|
||||||
const theCase = await this.cases.findByCaseNumber(args.caseNumber);
|
let theCase: Case;
|
||||||
if (!theCase) {
|
if (args.caseNumber != null) {
|
||||||
msg.channel.createMessage(errorMessage("Case not found"));
|
theCase = await this.cases.findByCaseNumber(args.caseNumber);
|
||||||
return;
|
} else {
|
||||||
|
theCase = await this.cases.findLatestByModId(msg.author.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.actions.fire("createCaseNote", {
|
|
||||||
caseId: theCase.id,
|
|
||||||
modId: msg.author.id,
|
|
||||||
note: args.note,
|
|
||||||
});
|
|
||||||
|
|
||||||
msg.channel.createMessage(successMessage(`Case \`#${theCase.case_number}\` updated`));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the latest case
|
|
||||||
*/
|
|
||||||
@d.command(/update|updatecase/, "<note:string$>")
|
|
||||||
@d.permission("can_note")
|
|
||||||
async updateLatestCmd(msg: Message, args: { note: string }) {
|
|
||||||
const theCase = await this.cases.findLatestByModId(msg.author.id);
|
|
||||||
if (!theCase) {
|
if (!theCase) {
|
||||||
msg.channel.createMessage(errorMessage("No latest case"));
|
msg.channel.createMessage(errorMessage("Case not found"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue