2021-06-06 23:51:32 +02:00
|
|
|
import { GuildAuditLogs } from "discord.js";
|
2020-10-01 01:43:38 +03:00
|
|
|
import { LogType } from "../../../data/LogType";
|
2021-08-18 01:51:42 +03:00
|
|
|
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
|
2020-08-05 02:25:13 +03:00
|
|
|
import { safeFindRelevantAuditLogEntry } from "../../../utils/safeFindRelevantAuditLogEntry";
|
2021-06-06 23:51:32 +02:00
|
|
|
import { logsEvt } from "../types";
|
2021-08-18 01:51:42 +03:00
|
|
|
import { logMemberBan } from "../logFunctions/logMemberBan";
|
|
|
|
import { isLogIgnored } from "../util/isLogIgnored";
|
|
|
|
import { logMemberUnban } from "../logFunctions/logMemberUnban";
|
2021-06-06 23:51:32 +02:00
|
|
|
|
2020-10-01 01:43:38 +03:00
|
|
|
export const LogsGuildBanAddEvt = logsEvt({
|
2020-07-27 01:53:14 +02:00
|
|
|
event: "guildBanAdd",
|
|
|
|
|
|
|
|
async listener(meta) {
|
|
|
|
const pluginData = meta.pluginData;
|
2021-06-01 04:33:02 +02:00
|
|
|
const user = meta.args.ban.user;
|
2020-07-27 01:53:14 +02:00
|
|
|
|
2021-08-18 01:51:42 +03:00
|
|
|
if (isLogIgnored(pluginData, LogType.MEMBER_BAN, user.id)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-08-05 02:25:13 +03:00
|
|
|
const relevantAuditLogEntry = await safeFindRelevantAuditLogEntry(
|
|
|
|
pluginData,
|
2021-06-01 04:33:02 +02:00
|
|
|
GuildAuditLogs.Actions.MEMBER_BAN_ADD as number,
|
2020-07-27 01:53:14 +02:00
|
|
|
user.id,
|
|
|
|
);
|
2021-07-28 23:27:07 +01:00
|
|
|
const mod = relevantAuditLogEntry?.executor ?? null;
|
2021-08-18 01:51:42 +03:00
|
|
|
logMemberBan(meta.pluginData, {
|
|
|
|
mod,
|
|
|
|
user,
|
|
|
|
caseNumber: 0,
|
|
|
|
reason: "",
|
|
|
|
});
|
2020-07-27 01:53:14 +02:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2020-10-01 01:43:38 +03:00
|
|
|
export const LogsGuildBanRemoveEvt = logsEvt({
|
2020-07-27 01:53:14 +02:00
|
|
|
event: "guildBanRemove",
|
|
|
|
|
|
|
|
async listener(meta) {
|
|
|
|
const pluginData = meta.pluginData;
|
2021-06-01 04:33:02 +02:00
|
|
|
const user = meta.args.ban.user;
|
2020-07-27 01:53:14 +02:00
|
|
|
|
2021-08-18 01:51:42 +03:00
|
|
|
if (isLogIgnored(pluginData, LogType.MEMBER_UNBAN, user.id)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-08-05 02:25:13 +03:00
|
|
|
const relevantAuditLogEntry = await safeFindRelevantAuditLogEntry(
|
|
|
|
pluginData,
|
2021-06-01 04:33:02 +02:00
|
|
|
GuildAuditLogs.Actions.MEMBER_BAN_REMOVE as number,
|
2020-07-27 01:53:14 +02:00
|
|
|
user.id,
|
|
|
|
);
|
2021-07-28 23:27:07 +01:00
|
|
|
const mod = relevantAuditLogEntry?.executor ?? null;
|
2020-07-27 01:53:14 +02:00
|
|
|
|
2021-08-18 01:51:42 +03:00
|
|
|
logMemberUnban(pluginData, {
|
|
|
|
mod,
|
|
|
|
userId: user.id,
|
|
|
|
caseNumber: 0,
|
|
|
|
reason: "",
|
|
|
|
});
|
2020-07-27 01:53:14 +02:00
|
|
|
},
|
|
|
|
});
|