3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-12 04:55:01 +00:00

Typed log functions + more

This commit is contained in:
Dragory 2021-08-18 01:51:42 +03:00
parent d2ac700143
commit bed6589d48
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
166 changed files with 4021 additions and 869 deletions

View file

@ -1,5 +1,5 @@
import { GuildAuditLogs, User } from "discord.js";
import { userToConfigAccessibleUser } from "../../../utils/configAccessibleObjects";
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
import { CaseTypes } from "../../../data/CaseTypes";
import { Case } from "../../../data/entities/Case";
import { LogType } from "../../../data/LogType";
@ -9,6 +9,7 @@ import { CasesPlugin } from "../../Cases/CasesPlugin";
import { clearIgnoredEvents } from "../functions/clearIgnoredEvents";
import { isEventIgnored } from "../functions/isEventIgnored";
import { IgnoredEventType, modActionsEvt } from "../types";
import { LogsPlugin } from "../../Logs/LogsPlugin";
/**
* Create a BAN case automatically when a user is banned manually.
@ -65,9 +66,9 @@ export const CreateBanCaseOnManualBanEvt = modActionsEvt({
}
}
pluginData.state.serverLogs.log(LogType.MEMBER_BAN, {
mod: mod ? userToConfigAccessibleUser(mod) : null,
user: userToConfigAccessibleUser(user),
pluginData.getPlugin(LogsPlugin).logMemberBan({
mod: mod ? userToTemplateSafeUser(mod) : null,
user: userToTemplateSafeUser(user),
caseNumber: createdCase?.case_number ?? 0,
reason,
});

View file

@ -1,5 +1,5 @@
import { GuildAuditLogs, User } from "discord.js";
import { userToConfigAccessibleUser } from "../../../utils/configAccessibleObjects";
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
import { CaseTypes } from "../../../data/CaseTypes";
import { Case } from "../../../data/entities/Case";
import { LogType } from "../../../data/LogType";
@ -10,6 +10,7 @@ import { CasesPlugin } from "../../Cases/CasesPlugin";
import { clearIgnoredEvents } from "../functions/clearIgnoredEvents";
import { isEventIgnored } from "../functions/isEventIgnored";
import { IgnoredEventType, modActionsEvt } from "../types";
import { LogsPlugin } from "../../Logs/LogsPlugin";
/**
* Create a KICK case automatically when a user is kicked manually.
@ -58,9 +59,9 @@ export const CreateKickCaseOnManualKickEvt = modActionsEvt({
}
}
pluginData.state.serverLogs.log(LogType.MEMBER_KICK, {
user: userToConfigAccessibleUser(member.user!),
mod: mod ? userToConfigAccessibleUser(mod) : null,
pluginData.getPlugin(LogsPlugin).logMemberKick({
user: member.user!,
mod,
caseNumber: createdCase?.case_number ?? 0,
reason: kickAuditLogEntry.reason || "",
});

View file

@ -1,5 +1,5 @@
import { GuildAuditLogs, User } from "discord.js";
import { userToConfigAccessibleUser } from "../../../utils/configAccessibleObjects";
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
import { CaseTypes } from "../../../data/CaseTypes";
import { Case } from "../../../data/entities/Case";
import { LogType } from "../../../data/LogType";
@ -9,6 +9,7 @@ import { CasesPlugin } from "../../Cases/CasesPlugin";
import { clearIgnoredEvents } from "../functions/clearIgnoredEvents";
import { isEventIgnored } from "../functions/isEventIgnored";
import { IgnoredEventType, modActionsEvt } from "../types";
import { LogsPlugin } from "../../Logs/LogsPlugin";
/**
* Create an UNBAN case automatically when a user is unbanned manually.
@ -63,10 +64,11 @@ export const CreateUnbanCaseOnManualUnbanEvt = modActionsEvt({
}
}
pluginData.state.serverLogs.log(LogType.MEMBER_UNBAN, {
mod: mod ? userToConfigAccessibleUser(mod) : null,
pluginData.getPlugin(LogsPlugin).logMemberUnban({
mod,
userId: user.id,
caseNumber: createdCase?.case_number ?? 0,
reason: "",
});
pluginData.state.events.emit("unban", user.id);

View file

@ -24,14 +24,14 @@ export const PostAlertOnMemberJoinEvt = modActionsEvt({
if (actions.length) {
const alertChannel = pluginData.guild.channels.cache.get(alertChannelId as Snowflake);
if (!alertChannel) {
logs.log(LogType.BOT_ALERT, {
logs.logBotAlert({
body: `Unknown \`alert_channel\` configured for \`mod_actions\`: \`${alertChannelId}\``,
});
return;
}
if (!(alertChannel instanceof TextChannel)) {
logs.log(LogType.BOT_ALERT, {
logs.logBotAlert({
body: `Non-text channel configured as \`alert_channel\` in \`mod_actions\`: \`${alertChannelId}\``,
});
return;
@ -40,7 +40,7 @@ export const PostAlertOnMemberJoinEvt = modActionsEvt({
const botMember = await resolveMember(pluginData.client, pluginData.guild, pluginData.client.user!.id);
const botPerms = alertChannel.permissionsFor(botMember ?? pluginData.client.user!.id);
if (!hasDiscordPermissions(botPerms, Permissions.FLAGS.SEND_MESSAGES)) {
logs.log(LogType.BOT_ALERT, {
logs.logBotAlert({
body: `Missing "Send Messages" permissions for the \`alert_channel\` configured in \`mod_actions\`: \`${alertChannelId}\``,
});
return;