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-06-06 23:51:32 +02:00
|
|
|
import { stripObjectToScalars, UnknownUser } from "../../../utils";
|
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";
|
|
|
|
|
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
|
|
|
|
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-06-01 04:33:02 +02:00
|
|
|
const mod = relevantAuditLogEntry ? relevantAuditLogEntry.executor : new UnknownUser();
|
2020-07-27 01:53:14 +02:00
|
|
|
|
|
|
|
pluginData.state.guildLogs.log(
|
|
|
|
LogType.MEMBER_BAN,
|
|
|
|
{
|
|
|
|
mod: stripObjectToScalars(mod),
|
|
|
|
user: stripObjectToScalars(user),
|
|
|
|
},
|
|
|
|
user.id,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
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
|
|
|
|
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-06-01 04:33:02 +02:00
|
|
|
const mod = relevantAuditLogEntry ? relevantAuditLogEntry.executor : new UnknownUser();
|
2020-07-27 01:53:14 +02:00
|
|
|
|
|
|
|
pluginData.state.guildLogs.log(
|
|
|
|
LogType.MEMBER_UNBAN,
|
|
|
|
{
|
|
|
|
mod: stripObjectToScalars(mod),
|
|
|
|
userId: user.id,
|
|
|
|
},
|
|
|
|
user.id,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|