Save moderation actions to database

This commit is contained in:
Ethan Lane 2022-08-17 18:09:55 +01:00
parent eef01b1c3d
commit 4812f5b691
Signed by: Vylpes
GPG key ID: EED233CC06D12504
4 changed files with 56 additions and 0 deletions

View file

@ -5,6 +5,9 @@ import PublicEmbed from "../helpers/embeds/PublicEmbed";
import { Command } from "../type/command";
import { ICommandContext } from "../contracts/ICommandContext";
import ICommandReturnContext from "../contracts/ICommandReturnContext";
import Audit from "../entity/Audit";
import { AuditType } from "../constants/AuditType";
import Server from "../entity/Server";
export default class Ban extends Command {
constructor() {
@ -75,6 +78,17 @@ export default class Ban extends Command {
await logEmbed.SendToModLogsChannel();
await publicEmbed.SendToCurrentChannel();
if (context.message.guild) {
const server = await Server.FetchOneById(Server, context.message.guild.id);
if (server) {
const audit = new Audit(targetUser.id, AuditType.Ban, reason, context.message.author.id);
audit.AssignToServer(server);
await audit.Save(Audit, audit);
}
}
return {
commandContext: context,
embeds: [logEmbed, publicEmbed],

View file

@ -1,6 +1,9 @@
import { AuditType } from "../constants/AuditType";
import ErrorMessages from "../constants/ErrorMessages";
import { ICommandContext } from "../contracts/ICommandContext";
import ICommandReturnContext from "../contracts/ICommandReturnContext";
import Audit from "../entity/Audit";
import Server from "../entity/Server";
import ErrorEmbed from "../helpers/embeds/ErrorEmbed";
import LogEmbed from "../helpers/embeds/LogEmbed";
import PublicEmbed from "../helpers/embeds/PublicEmbed";
@ -75,6 +78,17 @@ export default class Kick extends Command {
await logEmbed.SendToModLogsChannel();
await publicEmbed.SendToCurrentChannel();
if (context.message.guild) {
const server = await Server.FetchOneById(Server, context.message.guild.id);
if (server) {
const audit = new Audit(targetUser.id, AuditType.Kick, reason, context.message.author.id);
audit.AssignToServer(server);
await audit.Save(Audit, audit);
}
}
return {
commandContext: context,
embeds: [logEmbed, publicEmbed]

View file

@ -1,6 +1,9 @@
import { AuditType } from "../constants/AuditType";
import ErrorMessages from "../constants/ErrorMessages";
import { ICommandContext } from "../contracts/ICommandContext";
import ICommandReturnContext from "../contracts/ICommandReturnContext";
import Audit from "../entity/Audit";
import Server from "../entity/Server";
import ErrorEmbed from "../helpers/embeds/ErrorEmbed";
import LogEmbed from "../helpers/embeds/LogEmbed";
import PublicEmbed from "../helpers/embeds/PublicEmbed";
@ -88,6 +91,17 @@ export default class Mute extends Command {
await logEmbed.SendToModLogsChannel();
await publicEmbed.SendToCurrentChannel();
if (context.message.guild) {
const server = await Server.FetchOneById(Server, context.message.guild.id);
if (server) {
const audit = new Audit(targetUser.id, AuditType.Mute, reason, context.message.author.id);
audit.AssignToServer(server);
await audit.Save(Audit, audit);
}
}
return {
commandContext: context,
embeds: [logEmbed, publicEmbed]

View file

@ -1,5 +1,8 @@
import { AuditType } from "../constants/AuditType";
import { ICommandContext } from "../contracts/ICommandContext";
import ICommandReturnContext from "../contracts/ICommandReturnContext";
import Audit from "../entity/Audit";
import Server from "../entity/Server";
import ErrorEmbed from "../helpers/embeds/ErrorEmbed";
import LogEmbed from "../helpers/embeds/LogEmbed";
import PublicEmbed from "../helpers/embeds/PublicEmbed";
@ -63,6 +66,17 @@ export default class Warn extends Command {
await logEmbed.SendToModLogsChannel();
await publicEmbed.SendToCurrentChannel();
if (context.message.guild) {
const server = await Server.FetchOneById(Server, context.message.guild.id);
if (server) {
const audit = new Audit(user.id, AuditType.Warn, reason, context.message.author.id);
audit.AssignToServer(server);
await audit.Save(Audit, audit);
}
}
return {
commandContext: context,
embeds: [logEmbed, publicEmbed]