mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-18 23:09:59 +00:00
61 lines
1.7 KiB
TypeScript
61 lines
1.7 KiB
TypeScript
import { GuildAuditLogs } from "discord.js";
|
|
import { LogType } from "../../../data/LogType";
|
|
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
|
|
import { safeFindRelevantAuditLogEntry } from "../../../utils/safeFindRelevantAuditLogEntry";
|
|
import { logsEvt } from "../types";
|
|
import { logMemberBan } from "../logFunctions/logMemberBan";
|
|
import { isLogIgnored } from "../util/isLogIgnored";
|
|
import { logMemberUnban } from "../logFunctions/logMemberUnban";
|
|
|
|
export const LogsGuildBanAddEvt = logsEvt({
|
|
event: "guildBanAdd",
|
|
|
|
async listener(meta) {
|
|
const pluginData = meta.pluginData;
|
|
const user = meta.args.ban.user;
|
|
|
|
if (isLogIgnored(pluginData, LogType.MEMBER_BAN, user.id)) {
|
|
return;
|
|
}
|
|
|
|
const relevantAuditLogEntry = await safeFindRelevantAuditLogEntry(
|
|
pluginData,
|
|
GuildAuditLogs.Actions.MEMBER_BAN_ADD as number,
|
|
user.id,
|
|
);
|
|
const mod = relevantAuditLogEntry?.executor ?? null;
|
|
logMemberBan(meta.pluginData, {
|
|
mod,
|
|
user,
|
|
caseNumber: 0,
|
|
reason: "",
|
|
});
|
|
},
|
|
});
|
|
|
|
export const LogsGuildBanRemoveEvt = logsEvt({
|
|
event: "guildBanRemove",
|
|
|
|
async listener(meta) {
|
|
const pluginData = meta.pluginData;
|
|
const user = meta.args.ban.user;
|
|
|
|
if (isLogIgnored(pluginData, LogType.MEMBER_UNBAN, user.id)) {
|
|
return;
|
|
}
|
|
|
|
const relevantAuditLogEntry = await safeFindRelevantAuditLogEntry(
|
|
pluginData,
|
|
GuildAuditLogs.Actions.MEMBER_BAN_REMOVE as number,
|
|
user.id,
|
|
);
|
|
const mod = relevantAuditLogEntry?.executor ?? null;
|
|
|
|
logMemberUnban(pluginData, {
|
|
mod,
|
|
userId: user.id,
|
|
caseNumber: 0,
|
|
reason: "",
|
|
});
|
|
},
|
|
});
|