diff --git a/src/commands/audits.ts b/src/commands/audits.ts index fb28026..f0138b5 100644 --- a/src/commands/audits.ts +++ b/src/commands/audits.ts @@ -26,6 +26,9 @@ export default class Audits extends Command { case "view": await this.SendAudit(context); break; + case "clear": + await this.ClearAudit(context); + break; default: await this.SendUsage(context); } @@ -37,6 +40,7 @@ export default class Audits extends Command { const description = [ `\`${prefix}audits user \` - Send the audits for this user`, `\`${prefix}audits view \` - Send information about an audit`, + `\`${prefix}audits clear \` - Clears an audit for a user by audit id`, ] const publicEmbed = new PublicEmbed(context, "Usage", description.join("\n")); @@ -89,4 +93,27 @@ export default class Audits extends Command { await publicEmbed.SendToCurrentChannel(); } + + private async ClearAudit(context: ICommandContext) { + const auditId = context.args[1]; + + if (!auditId) { + await this.SendUsage(context); + return; + } + + const audit = await Audit.FetchAuditByAuditId(auditId.toUpperCase(), context.message.guild!.id); + + if (!audit) { + const errorEmbed = new ErrorEmbed(context, "This audit can not be found."); + await errorEmbed.SendToCurrentChannel(); + + return; + } + + await Audit.Remove(Audit, audit); + + const publicEmbed = new PublicEmbed(context, "", "Audit cleared"); + await publicEmbed.SendToCurrentChannel(); + } } \ No newline at end of file