3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-24 01:55:03 +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

@ -4,7 +4,7 @@ import { GuildPluginData } from "knub";
import moment from "moment-timezone";
import { LogType } from "src/data/LogType";
import { logger } from "src/logger";
import { userToConfigAccessibleUser } from "../../../utils/configAccessibleObjects";
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
import { CaseTypes } from "../../../data/CaseTypes";
import { resolveUser, SECONDS } from "../../../utils";
import { CasesPlugin } from "../../Cases/CasesPlugin";
@ -12,6 +12,7 @@ import { IgnoredEventType, ModActionsPluginType } from "../types";
import { formatReasonWithAttachments } from "./formatReasonWithAttachments";
import { ignoreEvent } from "./ignoreEvent";
import { isBanned } from "./isBanned";
import { LogsPlugin } from "../../Logs/LogsPlugin";
const TEMPBAN_LOOP_TIME = 60 * SECONDS;
@ -34,7 +35,7 @@ export async function outdatedTempbansLoop(pluginData: GuildPluginData<ModAction
ignoreEvent(pluginData, IgnoredEventType.Unban, tempban.user_id);
await pluginData.guild.bans.remove(tempban.user_id as Snowflake, reason ?? undefined);
} catch (e) {
pluginData.state.serverLogs.log(LogType.BOT_ALERT, {
pluginData.getPlugin(LogsPlugin).logBotAlert({
body: `Encountered an error trying to automatically unban ${tempban.user_id} after tempban timeout`,
});
logger.warn(`Error automatically unbanning ${tempban.user_id} (tempban timeout): ${e}`);
@ -54,8 +55,8 @@ export async function outdatedTempbansLoop(pluginData: GuildPluginData<ModAction
// Log the unban
const banTime = moment(tempban.created_at).diff(moment(tempban.expires_at));
pluginData.state.serverLogs.log(LogType.MEMBER_TIMED_UNBAN, {
mod: userToConfigAccessibleUser(await resolveUser(pluginData.client, tempban.mod_id)),
pluginData.getPlugin(LogsPlugin).logMemberTimedUnban({
mod: await resolveUser(pluginData.client, tempban.mod_id),
userId: tempban.user_id,
caseNumber: createdCase.case_number,
reason,