Save moderation actions to database
This commit is contained in:
parent
eef01b1c3d
commit
4812f5b691
4 changed files with 56 additions and 0 deletions
|
@ -5,6 +5,9 @@ import PublicEmbed from "../helpers/embeds/PublicEmbed";
|
||||||
import { Command } from "../type/command";
|
import { Command } from "../type/command";
|
||||||
import { ICommandContext } from "../contracts/ICommandContext";
|
import { ICommandContext } from "../contracts/ICommandContext";
|
||||||
import ICommandReturnContext from "../contracts/ICommandReturnContext";
|
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 {
|
export default class Ban extends Command {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -75,6 +78,17 @@ export default class Ban extends Command {
|
||||||
await logEmbed.SendToModLogsChannel();
|
await logEmbed.SendToModLogsChannel();
|
||||||
await publicEmbed.SendToCurrentChannel();
|
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 {
|
return {
|
||||||
commandContext: context,
|
commandContext: context,
|
||||||
embeds: [logEmbed, publicEmbed],
|
embeds: [logEmbed, publicEmbed],
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
|
import { AuditType } from "../constants/AuditType";
|
||||||
import ErrorMessages from "../constants/ErrorMessages";
|
import ErrorMessages from "../constants/ErrorMessages";
|
||||||
import { ICommandContext } from "../contracts/ICommandContext";
|
import { ICommandContext } from "../contracts/ICommandContext";
|
||||||
import ICommandReturnContext from "../contracts/ICommandReturnContext";
|
import ICommandReturnContext from "../contracts/ICommandReturnContext";
|
||||||
|
import Audit from "../entity/Audit";
|
||||||
|
import Server from "../entity/Server";
|
||||||
import ErrorEmbed from "../helpers/embeds/ErrorEmbed";
|
import ErrorEmbed from "../helpers/embeds/ErrorEmbed";
|
||||||
import LogEmbed from "../helpers/embeds/LogEmbed";
|
import LogEmbed from "../helpers/embeds/LogEmbed";
|
||||||
import PublicEmbed from "../helpers/embeds/PublicEmbed";
|
import PublicEmbed from "../helpers/embeds/PublicEmbed";
|
||||||
|
@ -75,6 +78,17 @@ export default class Kick extends Command {
|
||||||
await logEmbed.SendToModLogsChannel();
|
await logEmbed.SendToModLogsChannel();
|
||||||
await publicEmbed.SendToCurrentChannel();
|
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 {
|
return {
|
||||||
commandContext: context,
|
commandContext: context,
|
||||||
embeds: [logEmbed, publicEmbed]
|
embeds: [logEmbed, publicEmbed]
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
|
import { AuditType } from "../constants/AuditType";
|
||||||
import ErrorMessages from "../constants/ErrorMessages";
|
import ErrorMessages from "../constants/ErrorMessages";
|
||||||
import { ICommandContext } from "../contracts/ICommandContext";
|
import { ICommandContext } from "../contracts/ICommandContext";
|
||||||
import ICommandReturnContext from "../contracts/ICommandReturnContext";
|
import ICommandReturnContext from "../contracts/ICommandReturnContext";
|
||||||
|
import Audit from "../entity/Audit";
|
||||||
|
import Server from "../entity/Server";
|
||||||
import ErrorEmbed from "../helpers/embeds/ErrorEmbed";
|
import ErrorEmbed from "../helpers/embeds/ErrorEmbed";
|
||||||
import LogEmbed from "../helpers/embeds/LogEmbed";
|
import LogEmbed from "../helpers/embeds/LogEmbed";
|
||||||
import PublicEmbed from "../helpers/embeds/PublicEmbed";
|
import PublicEmbed from "../helpers/embeds/PublicEmbed";
|
||||||
|
@ -88,6 +91,17 @@ export default class Mute extends Command {
|
||||||
await logEmbed.SendToModLogsChannel();
|
await logEmbed.SendToModLogsChannel();
|
||||||
await publicEmbed.SendToCurrentChannel();
|
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 {
|
return {
|
||||||
commandContext: context,
|
commandContext: context,
|
||||||
embeds: [logEmbed, publicEmbed]
|
embeds: [logEmbed, publicEmbed]
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
|
import { AuditType } from "../constants/AuditType";
|
||||||
import { ICommandContext } from "../contracts/ICommandContext";
|
import { ICommandContext } from "../contracts/ICommandContext";
|
||||||
import ICommandReturnContext from "../contracts/ICommandReturnContext";
|
import ICommandReturnContext from "../contracts/ICommandReturnContext";
|
||||||
|
import Audit from "../entity/Audit";
|
||||||
|
import Server from "../entity/Server";
|
||||||
import ErrorEmbed from "../helpers/embeds/ErrorEmbed";
|
import ErrorEmbed from "../helpers/embeds/ErrorEmbed";
|
||||||
import LogEmbed from "../helpers/embeds/LogEmbed";
|
import LogEmbed from "../helpers/embeds/LogEmbed";
|
||||||
import PublicEmbed from "../helpers/embeds/PublicEmbed";
|
import PublicEmbed from "../helpers/embeds/PublicEmbed";
|
||||||
|
@ -63,6 +66,17 @@ export default class Warn extends Command {
|
||||||
await logEmbed.SendToModLogsChannel();
|
await logEmbed.SendToModLogsChannel();
|
||||||
await publicEmbed.SendToCurrentChannel();
|
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 {
|
return {
|
||||||
commandContext: context,
|
commandContext: context,
|
||||||
embeds: [logEmbed, publicEmbed]
|
embeds: [logEmbed, publicEmbed]
|
||||||
|
|
Loading…
Reference in a new issue