3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 12:25:02 +00:00

Allow for caseNumber in Logs, showing the case number - repalce log evts

This commit is contained in:
Dark 2020-08-02 02:30:01 +02:00
parent 6caf7b1304
commit e131c77e20
13 changed files with 51 additions and 64 deletions

View file

@ -6,6 +6,8 @@ import { Constants as ErisConstants } from "eris";
import { safeFindRelevantAuditLogEntry } from "../functions/safeFindRelevantAuditLogEntry";
import { CasesPlugin } from "../../Cases/CasesPlugin";
import { CaseTypes } from "../../../data/CaseTypes";
import { LogType } from "src/data/LogType";
import { stripObjectToScalars, resolveUser } from "src/utils";
/**
* Create a BAN case automatically when a user is banned manually.
@ -26,24 +28,39 @@ export const CreateBanCaseOnManualBanEvt = eventListener<ModActionsPluginType>()
);
const casesPlugin = pluginData.getPlugin(CasesPlugin);
let createdCase;
let mod = null;
let reason = "";
if (relevantAuditLogEntry) {
const modId = relevantAuditLogEntry.user.id;
const auditLogId = relevantAuditLogEntry.id;
casesPlugin.createCase({
mod = resolveUser(pluginData.client, modId);
reason = relevantAuditLogEntry.reason;
createdCase = await casesPlugin.createCase({
userId: user.id,
modId,
type: CaseTypes.Ban,
auditLogId,
reason: relevantAuditLogEntry.reason,
reason,
automatic: true,
});
} else {
casesPlugin.createCase({
createdCase = await casesPlugin.createCase({
userId: user.id,
modId: null,
type: CaseTypes.Ban,
});
}
mod = await mod;
pluginData.state.serverLogs.log(LogType.MEMBER_BAN, {
mod: mod ? stripObjectToScalars(mod, ["user"]) : null,
user: stripObjectToScalars(user, ["user"]),
caseNumber: createdCase.case_number,
reason,
});
},
);