Feature/vba 77 #178

Merged
Vylpes merged 13 commits from feature/VBA-77 into develop 2022-09-05 18:10:04 +01:00
2 changed files with 33 additions and 2 deletions
Showing only changes of commit b85af78e5c - Show all commits

View file

@ -4,6 +4,7 @@ import AuditTools from "../helpers/AuditTools";
import PublicEmbed from "../helpers/embeds/PublicEmbed";
import { Command } from "../type/command";
import SettingsHelper from "../helpers/SettingsHelper";
import ErrorEmbed from "../helpers/embeds/ErrorEmbed";
export default class Audits extends Command {
constructor() {
@ -22,6 +23,9 @@ export default class Audits extends Command {
case "user":
await this.SendAuditForUser(context);
break;
case "view":
await this.SendAudit(context);
break;
default:
await this.SendUsage(context);
}
@ -32,6 +36,7 @@ export default class Audits extends Command {
const description = [
`\`${prefix}audits user <id>\` - Send the audits for this user`,
`\`${prefix}audits view <id>\` - Send information about an audit`,
]
const publicEmbed = new PublicEmbed(context, "Usage", description.join("\n"));
@ -58,4 +63,30 @@ export default class Audits extends Command {
await publicEmbed.SendToCurrentChannel();
}
VylpesTester commented 2022-08-20 21:00:14 +01:00 (Migrated from github.com)
Review

Add user tag

Add user tag
private async SendAudit(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;
}
const publicEmbed = new PublicEmbed(context, `Audit ${audit.AuditId.toUpperCase()}`, "");
publicEmbed.addField("Reason", audit.Reason, true);
publicEmbed.addField("Type", AuditTools.TypeToFriendlyText(audit.AuditType), true);
publicEmbed.addField("Moderator", `<@${audit.ModeratorId}>`, true);
await publicEmbed.SendToCurrentChannel();
}
}
VylpesTester commented 2022-08-20 21:00:25 +01:00 (Migrated from github.com)
Review

Add user tag

Add user tag

View file

@ -44,12 +44,12 @@ export default class Audit extends BaseEntity {
return all;
}
public static async FetchAuditByAuditId(auditId: string): Promise<Audit | undefined> {
public static async FetchAuditByAuditId(auditId: string, serverId: string): Promise<Audit | undefined> {
const connection = getConnection();
const repository = connection.getRepository(Audit);
const single = await repository.findOne({ AuditId: auditId });
const single = await repository.findOne({ AuditId: auditId, ServerId: serverId });
return single;
}