3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-18 15:00:00 +00:00
zeppelin/backend/src/data/ApiAuditLog.ts
2023-07-01 12:17:45 +00:00

28 lines
821 B
TypeScript

import { Repository } from "typeorm/index";
import { BaseRepository } from "./BaseRepository";
import { AuditLogEventData, AuditLogEventType } from "./apiAuditLogTypes";
import { dataSource } from "./dataSource";
import { ApiAuditLogEntry } from "./entities/ApiAuditLogEntry";
export class ApiAuditLog extends BaseRepository {
private auditLog: Repository<ApiAuditLogEntry<any>>;
constructor() {
super();
this.auditLog = dataSource.getRepository(ApiAuditLogEntry);
}
addEntry<TEventType extends AuditLogEventType>(
guildId: string,
authorId: string,
eventType: TEventType,
eventData: AuditLogEventData[TEventType],
) {
this.auditLog.insert({
guild_id: guildId,
author_id: authorId,
event_type: eventType as any,
event_data: eventData as any,
});
}
}