diff --git a/src/data/GuildCases.ts b/src/data/GuildCases.ts index 5ebb697f..afad41bc 100644 --- a/src/data/GuildCases.ts +++ b/src/data/GuildCases.ts @@ -70,6 +70,20 @@ export class GuildCases extends BaseRepository { }); } + async getRecent(count: number): Promise { + return this.cases.find({ + relations: this.getRelations(), + where: { + guild_id: this.guildId, + is_hidden: 0, + }, + take: count, + order: { + case_number: "DESC", + }, + }); + } + async setHidden(id: number, hidden: boolean): Promise { await this.cases.update( { id }, diff --git a/src/plugins/ModActions.ts b/src/plugins/ModActions.ts index d9684af3..59656a46 100644 --- a/src/plugins/ModActions.ts +++ b/src/plugins/ModActions.ts @@ -1039,7 +1039,6 @@ export class ModActionsPlugin extends ZeppelinPlugin { const user = this.bot.users.get(args.userId); const userName = user ? `${user.username}#${user.discriminator}` : "Unknown#0000"; - const prefix = this.knub.getGuildData(this.guildId).config.prefix; if (cases.length === 0) { msg.channel.createMessage(`No cases found for ${user ? `**${userName}**` : "the specified user"}`); @@ -1082,7 +1081,7 @@ export class ModActionsPlugin extends ZeppelinPlugin { ${lines.join("\n")} - Use \`${prefix}case \` to see more info about individual cases + Use the \`case \` command to see more info about individual cases `); createChunkedMessage(msg.channel, finalMessage); @@ -1090,6 +1089,26 @@ export class ModActionsPlugin extends ZeppelinPlugin { } } + @d.command("cases") + @d.permission("view") + async recentCasesCmd(msg: Message) { + const recentCases = await this.cases.with("notes").getRecent(5); + if (recentCases.length === 0) { + msg.channel.createMessage(errorMessage("No cases")); + } else { + const lines = recentCases.map(c => this.cases.getSummaryText(c)); + const finalMessage = trimLines(` + Most recent 5 cases: + + ${lines.join("\n")} + + Use the \`case \` command to see more info about individual cases + Use the \`cases \` command to see a specific user's cases + `); + createChunkedMessage(msg.channel, finalMessage); + } + } + @d.command("hidecase", "") @d.permission("hidecase") async hideCaseCmd(msg: Message, args: { caseNum: number }) {