Add optional 'expanded' param to !cases

This commit is contained in:
Dragory 2018-08-02 03:01:22 +03:00
parent 2aaacef2c3
commit 9769e38f17

View file

@ -691,9 +691,9 @@ export class ModActionsPlugin extends Plugin {
this.displayCase(theCase.id, msg.channel.id);
}
@d.command(/cases|usercases/, "<userId:userId>")
@d.command(/cases|usercases/, "<userId:userId> [expanded:string]")
@d.permission("view")
async usercasesCmd(msg: Message, args: { userId: string }) {
async usercasesCmd(msg: Message, args: { userId: string; expanded?: string }) {
const cases = await this.cases.getByUserId(args.userId);
const user = this.bot.users.get(args.userId);
const userName = user ? `${user.username}#${user.discriminator}` : "Unknown#0000";
@ -702,6 +702,13 @@ export class ModActionsPlugin extends Plugin {
if (cases.length === 0) {
msg.channel.createMessage("No cases found for the specified user!");
} else {
if (args.expanded === "expanded") {
// Expanded view (= individual case embeds)
for (const theCase of cases) {
await this.displayCase(theCase.id, msg.channel.id);
}
} else {
// Compact view (= regular message with a preview of each case)
const lines = [];
for (const theCase of cases) {
const firstNote = await this.cases.findFirstCaseNote(theCase.id);
@ -733,6 +740,7 @@ export class ModActionsPlugin extends Plugin {
msg.channel.createMessage(finalMessage);
}
}
}
protected canActOn(member1, member2) {
if (member1.id === member2.id) {
@ -838,7 +846,7 @@ export class ModActionsPlugin extends Plugin {
}
const channel = this.guild.channels.get(channelId) as TextChannel;
channel.createMessage({ embed });
await channel.createMessage({ embed });
}
/**