Migrate Logs to new Plugin structure, also dont ignore it
This commit is contained in:
parent
140ba84544
commit
aea019181c
16 changed files with 764 additions and 1 deletions
54
backend/src/plugins/Logs/events/LogsGuildBanEvts.ts
Normal file
54
backend/src/plugins/Logs/events/LogsGuildBanEvts.ts
Normal file
|
@ -0,0 +1,54 @@
|
|||
import { logsEvent } from "../types";
|
||||
import { stripObjectToScalars, findRelevantAuditLogEntry, UnknownUser } from "src/utils";
|
||||
import { LogType } from "src/data/LogType";
|
||||
import { Constants as ErisConstants } from "eris";
|
||||
|
||||
export const LogsGuildBanAddEvt = logsEvent({
|
||||
event: "guildBanAdd",
|
||||
|
||||
async listener(meta) {
|
||||
const pluginData = meta.pluginData;
|
||||
const user = meta.args.user;
|
||||
|
||||
const relevantAuditLogEntry = await findRelevantAuditLogEntry(
|
||||
pluginData.guildConfig,
|
||||
ErisConstants.AuditLogActions.MEMBER_BAN_ADD,
|
||||
user.id,
|
||||
);
|
||||
const mod = relevantAuditLogEntry ? relevantAuditLogEntry.user : new UnknownUser();
|
||||
|
||||
pluginData.state.guildLogs.log(
|
||||
LogType.MEMBER_BAN,
|
||||
{
|
||||
mod: stripObjectToScalars(mod),
|
||||
user: stripObjectToScalars(user),
|
||||
},
|
||||
user.id,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
export const LogsGuildBanRemoveEvt = logsEvent({
|
||||
event: "guildBanRemove",
|
||||
|
||||
async listener(meta) {
|
||||
const pluginData = meta.pluginData;
|
||||
const user = meta.args.user;
|
||||
|
||||
const relevantAuditLogEntry = await findRelevantAuditLogEntry(
|
||||
pluginData.guild,
|
||||
ErisConstants.AuditLogActions.MEMBER_BAN_REMOVE,
|
||||
user.id,
|
||||
);
|
||||
const mod = relevantAuditLogEntry ? relevantAuditLogEntry.user : new UnknownUser();
|
||||
|
||||
pluginData.state.guildLogs.log(
|
||||
LogType.MEMBER_UNBAN,
|
||||
{
|
||||
mod: stripObjectToScalars(mod),
|
||||
userId: user.id,
|
||||
},
|
||||
user.id,
|
||||
);
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue