mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 20:35:02 +00:00
Add !deletecase
This commit is contained in:
parent
8826b2521d
commit
ddbbc543c2
9 changed files with 146 additions and 6 deletions
|
@ -6,6 +6,6 @@ export enum CaseTypes {
|
|||
Kick,
|
||||
Mute,
|
||||
Unmute,
|
||||
Expunged,
|
||||
Deleted,
|
||||
Softban,
|
||||
}
|
||||
|
|
|
@ -66,5 +66,7 @@
|
|||
"AUTOMOD_ACTION": "\uD83E\uDD16 Automod rule **{rule}** triggered by {userMention(users)}\n{matchSummary}\nActions taken: **{actionsTaken}**",
|
||||
|
||||
"SET_ANTIRAID_USER": "⚔ {userMention(user)} set anti-raid to **{level}**",
|
||||
"SET_ANTIRAID_AUTO": "⚔ Anti-raid automatically set to **{level}**"
|
||||
"SET_ANTIRAID_AUTO": "⚔ Anti-raid automatically set to **{level}**",
|
||||
|
||||
"CASE_DELETE": "✂️ **Case #{case.case_number}** was deleted by {userMention(mod)}"
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import { getRepository, In, Repository } from "typeorm";
|
|||
import { disableLinkPreviews } from "../utils";
|
||||
import { CaseTypes } from "./CaseTypes";
|
||||
import moment = require("moment-timezone");
|
||||
import { connection } from "./db";
|
||||
|
||||
const CASE_SUMMARY_REASON_MAX_LENGTH = 300;
|
||||
|
||||
|
@ -119,6 +120,37 @@ export class GuildCases extends BaseGuildRepository {
|
|||
return this.cases.update(id, data);
|
||||
}
|
||||
|
||||
async softDelete(id: number, deletedById: string, deletedByName: string, deletedByText: string) {
|
||||
return connection.transaction(async entityManager => {
|
||||
const cases = entityManager.getRepository(Case);
|
||||
const caseNotes = entityManager.getRepository(CaseNote);
|
||||
|
||||
await Promise.all([
|
||||
caseNotes.delete({
|
||||
case_id: id,
|
||||
}),
|
||||
cases.update(id, {
|
||||
user_id: "0",
|
||||
user_name: "Unknown#0000",
|
||||
mod_id: null,
|
||||
mod_name: "Unknown#0000",
|
||||
type: CaseTypes.Deleted,
|
||||
audit_log_id: null,
|
||||
is_hidden: false,
|
||||
pp_id: null,
|
||||
pp_name: null,
|
||||
}),
|
||||
]);
|
||||
|
||||
await caseNotes.insert({
|
||||
case_id: id,
|
||||
mod_id: deletedById,
|
||||
mod_name: deletedByName,
|
||||
body: deletedByText,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async createNote(caseId: number, data: any): Promise<void> {
|
||||
await this.caseNotes.insert({
|
||||
...data,
|
||||
|
|
|
@ -75,4 +75,6 @@ export enum LogType {
|
|||
MASS_UNASSIGN_ROLES,
|
||||
|
||||
MEMBER_NOTE,
|
||||
|
||||
CASE_DELETE,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue