mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
Typed log functions + more
This commit is contained in:
parent
d2ac700143
commit
bed6589d48
166 changed files with 4021 additions and 869 deletions
|
@ -46,6 +46,7 @@ import { outdatedTempbansLoop } from "./functions/outdatedTempbansLoop";
|
|||
import { updateCase } from "./functions/updateCase";
|
||||
import { warnMember } from "./functions/warnMember";
|
||||
import { BanOptions, ConfigSchema, KickOptions, ModActionsPluginType, WarnOptions } from "./types";
|
||||
import { LogsPlugin } from "../Logs/LogsPlugin";
|
||||
|
||||
const defaultOptions = {
|
||||
config: {
|
||||
|
@ -121,7 +122,7 @@ export const ModActionsPlugin = zeppelinGuildPlugin<ModActionsPluginType>()({
|
|||
`),
|
||||
},
|
||||
|
||||
dependencies: [TimeAndDatePlugin, CasesPlugin, MutesPlugin],
|
||||
dependencies: [TimeAndDatePlugin, CasesPlugin, MutesPlugin, LogsPlugin],
|
||||
configSchema: ConfigSchema,
|
||||
defaultOptions,
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { userToConfigAccessibleUser } from "../../../utils/configAccessibleObjects";
|
||||
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { Case } from "../../../data/entities/Case";
|
||||
|
@ -8,6 +8,7 @@ import { canActOn, hasPermission, sendErrorMessage, sendSuccessMessage } from ".
|
|||
import { resolveMember, resolveUser } from "../../../utils";
|
||||
import { formatReasonWithAttachments } from "../functions/formatReasonWithAttachments";
|
||||
import { modActionsCmd } from "../types";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
|
||||
const opts = {
|
||||
mod: ct.member({ option: true }),
|
||||
|
@ -79,8 +80,8 @@ export const AddCaseCmd = modActionsCmd({
|
|||
}
|
||||
|
||||
// Log the action
|
||||
pluginData.state.serverLogs.log(LogType.CASE_CREATE, {
|
||||
mod: userToConfigAccessibleUser(mod.user),
|
||||
pluginData.getPlugin(LogsPlugin).logCaseCreate({
|
||||
mod: mod.user,
|
||||
userId: user.id,
|
||||
caseNum: theCase.case_number,
|
||||
caseType: type.toUpperCase(),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import humanizeDuration from "humanize-duration";
|
||||
import { getMemberLevel } from "knub/dist/helpers";
|
||||
import { userToConfigAccessibleUser } from "../../../utils/configAccessibleObjects";
|
||||
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
@ -14,6 +14,7 @@ import { formatReasonWithAttachments } from "../functions/formatReasonWithAttach
|
|||
import { isBanned } from "../functions/isBanned";
|
||||
import { readContactMethodsFromArgs } from "../functions/readContactMethodsFromArgs";
|
||||
import { modActionsCmd } from "../types";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
|
||||
const opts = {
|
||||
mod: ct.member({ option: true }),
|
||||
|
@ -108,14 +109,22 @@ export const BanCmd = modActionsCmd({
|
|||
reason,
|
||||
noteDetails: [`Ban updated to ${time ? humanizeDuration(time) : "indefinite"}`],
|
||||
});
|
||||
const logtype = time ? LogType.MEMBER_TIMED_BAN : LogType.MEMBER_BAN;
|
||||
pluginData.state.serverLogs.log(logtype, {
|
||||
mod: userToConfigAccessibleUser(mod.user),
|
||||
user: userToConfigAccessibleUser(user),
|
||||
caseNumber: createdCase.case_number,
|
||||
reason,
|
||||
banTime: time ? humanizeDuration(time) : null,
|
||||
});
|
||||
if (time) {
|
||||
pluginData.getPlugin(LogsPlugin).logMemberTimedBan({
|
||||
mod: mod.user,
|
||||
user,
|
||||
caseNumber: createdCase.case_number,
|
||||
reason,
|
||||
banTime: humanizeDuration(time),
|
||||
});
|
||||
} else {
|
||||
pluginData.getPlugin(LogsPlugin).logMemberBan({
|
||||
mod,
|
||||
user,
|
||||
caseNumber: createdCase.case_number,
|
||||
reason,
|
||||
});
|
||||
}
|
||||
|
||||
sendSuccessMessage(
|
||||
pluginData,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { helpers } from "knub";
|
||||
import { memberToConfigAccessibleMember } from "../../../utils/configAccessibleObjects";
|
||||
import { memberToTemplateSafeMember } from "../../../utils/templateSafeObjects";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { Case } from "../../../data/entities/Case";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
@ -81,9 +81,9 @@ export const DeleteCaseCmd = modActionsCmd({
|
|||
);
|
||||
|
||||
const logs = pluginData.getPlugin(LogsPlugin);
|
||||
logs.log(LogType.CASE_DELETE, {
|
||||
mod: memberToConfigAccessibleMember(message.member),
|
||||
case: stripObjectToScalars(theCase),
|
||||
logs.logCaseDelete({
|
||||
mod: message.member,
|
||||
case: theCase,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import { userToConfigAccessibleUser } from "../../../utils/configAccessibleObjects";
|
||||
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
@ -10,6 +10,7 @@ import { formatReasonWithAttachments } from "../functions/formatReasonWithAttach
|
|||
import { ignoreEvent } from "../functions/ignoreEvent";
|
||||
import { isBanned } from "../functions/isBanned";
|
||||
import { IgnoredEventType, modActionsCmd } from "../types";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
|
||||
const opts = {
|
||||
mod: ct.member({ option: true }),
|
||||
|
@ -91,8 +92,8 @@ export const ForcebanCmd = modActionsCmd({
|
|||
sendSuccessMessage(pluginData, msg.channel, `Member forcebanned (Case #${createdCase.case_number})`);
|
||||
|
||||
// Log the action
|
||||
pluginData.state.serverLogs.log(LogType.MEMBER_FORCEBAN, {
|
||||
mod: userToConfigAccessibleUser(mod.user),
|
||||
pluginData.getPlugin(LogsPlugin).logMemberForceban({
|
||||
mod,
|
||||
userId: user.id,
|
||||
caseNumber: createdCase.case_number,
|
||||
reason,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { waitForReply } from "knub/dist/helpers";
|
||||
import { performance } from "perf_hooks";
|
||||
import { userToConfigAccessibleUser } from "../../../utils/configAccessibleObjects";
|
||||
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
@ -12,6 +12,7 @@ import { MINUTES, noop } from "../../../utils";
|
|||
import { formatReasonWithAttachments } from "../functions/formatReasonWithAttachments";
|
||||
import { ignoreEvent } from "../functions/ignoreEvent";
|
||||
import { IgnoredEventType, modActionsCmd } from "../types";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
|
||||
export const MassbanCmd = modActionsCmd({
|
||||
trigger: "massban",
|
||||
|
@ -129,8 +130,8 @@ export const MassbanCmd = modActionsCmd({
|
|||
sendErrorMessage(pluginData, msg.channel, "All bans failed. Make sure the IDs are valid.");
|
||||
} else {
|
||||
// Some or all bans were successful. Create a log entry for the mass ban and notify the user.
|
||||
pluginData.state.serverLogs.log(LogType.MASSBAN, {
|
||||
mod: userToConfigAccessibleUser(msg.author),
|
||||
pluginData.getPlugin(LogsPlugin).logMassBan({
|
||||
mod: msg.author,
|
||||
count: successfulBanCount,
|
||||
reason: banReason,
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { waitForReply } from "knub/dist/helpers";
|
||||
import { userToConfigAccessibleUser } from "../../../utils/configAccessibleObjects";
|
||||
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
@ -10,6 +10,7 @@ import { formatReasonWithAttachments } from "../functions/formatReasonWithAttach
|
|||
import { ignoreEvent } from "../functions/ignoreEvent";
|
||||
import { isBanned } from "../functions/isBanned";
|
||||
import { IgnoredEventType, modActionsCmd } from "../types";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
|
||||
export const MassunbanCmd = modActionsCmd({
|
||||
trigger: "massunban",
|
||||
|
@ -83,8 +84,8 @@ export const MassunbanCmd = modActionsCmd({
|
|||
sendErrorMessage(pluginData, msg.channel, "All unbans failed. Make sure the IDs are valid and banned.");
|
||||
} else {
|
||||
// Some or all unbans were successful. Create a log entry for the mass unban and notify the user.
|
||||
pluginData.state.serverLogs.log(LogType.MASSUNBAN, {
|
||||
mod: userToConfigAccessibleUser(msg.author),
|
||||
pluginData.getPlugin(LogsPlugin).logMassUnban({
|
||||
mod: msg.author,
|
||||
count: successfulUnbanCount,
|
||||
reason: unbanReason,
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { waitForReply } from "knub/dist/helpers";
|
||||
import { userToConfigAccessibleUser } from "../../../utils/configAccessibleObjects";
|
||||
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { logger } from "../../../logger";
|
||||
|
@ -8,6 +8,7 @@ import { MutesPlugin } from "../../../plugins/Mutes/MutesPlugin";
|
|||
import { canActOn, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { formatReasonWithAttachments } from "../functions/formatReasonWithAttachments";
|
||||
import { modActionsCmd } from "../types";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
|
||||
export const MassmuteCmd = modActionsCmd({
|
||||
trigger: "massmute",
|
||||
|
@ -86,8 +87,8 @@ export const MassmuteCmd = modActionsCmd({
|
|||
sendErrorMessage(pluginData, msg.channel, "All mutes failed. Make sure the IDs are valid.");
|
||||
} else {
|
||||
// Success on all or some mutes
|
||||
pluginData.state.serverLogs.log(LogType.MASSMUTE, {
|
||||
mod: userToConfigAccessibleUser(msg.author),
|
||||
pluginData.getPlugin(LogsPlugin).logMassMute({
|
||||
mod: msg.author,
|
||||
count: successfulMuteCount,
|
||||
});
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { userToConfigAccessibleUser } from "../../../utils/configAccessibleObjects";
|
||||
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
@ -7,6 +7,7 @@ import { resolveUser } from "../../../utils";
|
|||
import { CasesPlugin } from "../../Cases/CasesPlugin";
|
||||
import { formatReasonWithAttachments } from "../functions/formatReasonWithAttachments";
|
||||
import { modActionsCmd } from "../types";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
|
||||
export const NoteCmd = modActionsCmd({
|
||||
trigger: "note",
|
||||
|
@ -41,9 +42,9 @@ export const NoteCmd = modActionsCmd({
|
|||
reason,
|
||||
});
|
||||
|
||||
pluginData.state.serverLogs.log(LogType.MEMBER_NOTE, {
|
||||
mod: userToConfigAccessibleUser(msg.author),
|
||||
user: userToConfigAccessibleUser(user),
|
||||
pluginData.getPlugin(LogsPlugin).logMemberNote({
|
||||
mod: msg.author,
|
||||
user,
|
||||
caseNumber: createdCase.case_number,
|
||||
reason,
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import { userToConfigAccessibleUser } from "../../../utils/configAccessibleObjects";
|
||||
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
@ -9,6 +9,7 @@ import { resolveUser } from "../../../utils";
|
|||
import { formatReasonWithAttachments } from "../functions/formatReasonWithAttachments";
|
||||
import { ignoreEvent } from "../functions/ignoreEvent";
|
||||
import { IgnoredEventType, modActionsCmd } from "../types";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
|
||||
const opts = {
|
||||
mod: ct.member({ option: true }),
|
||||
|
@ -73,11 +74,11 @@ export const UnbanCmd = modActionsCmd({
|
|||
sendSuccessMessage(pluginData, msg.channel, `Member unbanned (Case #${createdCase.case_number})`);
|
||||
|
||||
// Log the action
|
||||
pluginData.state.serverLogs.log(LogType.MEMBER_UNBAN, {
|
||||
mod: userToConfigAccessibleUser(mod.user),
|
||||
pluginData.getPlugin(LogsPlugin).logMemberUnban({
|
||||
mod: mod.user,
|
||||
userId: user.id,
|
||||
caseNumber: createdCase.case_number,
|
||||
reason,
|
||||
reason: reason ?? "",
|
||||
});
|
||||
|
||||
pluginData.state.events.emit("unban", user.id);
|
||||
|
|
|
@ -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,
|
||||
});
|
||||
|
|
|
@ -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 || "",
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { DiscordAPIError, Snowflake, User } from "discord.js";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { userToConfigAccessibleUser } from "../../../utils/configAccessibleObjects";
|
||||
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { logger } from "../../../logger";
|
||||
|
@ -18,6 +18,7 @@ import { CasesPlugin } from "../../Cases/CasesPlugin";
|
|||
import { BanOptions, BanResult, IgnoredEventType, ModActionsPluginType } from "../types";
|
||||
import { getDefaultContactMethods } from "./getDefaultContactMethods";
|
||||
import { ignoreEvent } from "./ignoreEvent";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
|
||||
/**
|
||||
* Ban the specified user id, whether or not they're actually on the server at the time. Generates a case.
|
||||
|
@ -128,14 +129,23 @@ export async function banUserId(
|
|||
|
||||
// Log the action
|
||||
const mod = await resolveUser(pluginData.client, modId);
|
||||
const logtype = banTime ? LogType.MEMBER_TIMED_BAN : LogType.MEMBER_BAN;
|
||||
pluginData.state.serverLogs.log(logtype, {
|
||||
mod: userToConfigAccessibleUser(mod),
|
||||
user: userToConfigAccessibleUser(user),
|
||||
caseNumber: createdCase.case_number,
|
||||
reason,
|
||||
banTime: banTime ? humanizeDuration(banTime) : null,
|
||||
});
|
||||
|
||||
if (banTime) {
|
||||
pluginData.getPlugin(LogsPlugin).logMemberTimedBan({
|
||||
mod,
|
||||
user,
|
||||
caseNumber: createdCase.case_number,
|
||||
reason: reason ?? "",
|
||||
banTime: humanizeDuration(banTime),
|
||||
});
|
||||
} else {
|
||||
pluginData.getPlugin(LogsPlugin).logMemberBan({
|
||||
mod,
|
||||
user,
|
||||
caseNumber: createdCase.case_number,
|
||||
reason: reason ?? "",
|
||||
});
|
||||
}
|
||||
|
||||
pluginData.state.events.emit("ban", user.id, reason, banOptions.isAutomodAction);
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ export async function isBanned(
|
|||
): Promise<boolean> {
|
||||
const botMember = pluginData.guild.members.cache.get(pluginData.client.user!.id);
|
||||
if (botMember && !hasDiscordPermissions(botMember.permissions, Permissions.FLAGS.BAN_MEMBERS)) {
|
||||
pluginData.getPlugin(LogsPlugin).log(LogType.BOT_ALERT, {
|
||||
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
||||
body: `Missing "Ban Members" permission to check for existing bans`,
|
||||
});
|
||||
return false;
|
||||
|
@ -37,7 +37,7 @@ export async function isBanned(
|
|||
}
|
||||
|
||||
if (isDiscordAPIError(e) && e.code === 50013) {
|
||||
pluginData.getPlugin(LogsPlugin).log(LogType.BOT_ALERT, {
|
||||
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
||||
body: `Missing "Ban Members" permission to check for existing bans`,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { userToConfigAccessibleUser } from "../../../utils/configAccessibleObjects";
|
||||
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { renderTemplate } from "../../../templateFormatter";
|
||||
|
@ -9,6 +9,7 @@ import { CasesPlugin } from "../../Cases/CasesPlugin";
|
|||
import { IgnoredEventType, KickOptions, KickResult, ModActionsPluginType } from "../types";
|
||||
import { getDefaultContactMethods } from "./getDefaultContactMethods";
|
||||
import { ignoreEvent } from "./ignoreEvent";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
|
||||
/**
|
||||
* Kick the specified server member. Generates a case.
|
||||
|
@ -34,7 +35,7 @@ export async function kickMember(
|
|||
guildName: pluginData.guild.name,
|
||||
reason,
|
||||
moderator: kickOptions.caseArgs?.modId
|
||||
? userToConfigAccessibleUser(await resolveUser(pluginData.client, kickOptions.caseArgs.modId))
|
||||
? userToTemplateSafeUser(await resolveUser(pluginData.client, kickOptions.caseArgs.modId))
|
||||
: {},
|
||||
});
|
||||
|
||||
|
@ -72,11 +73,11 @@ export async function kickMember(
|
|||
|
||||
// Log the action
|
||||
const mod = await resolveUser(pluginData.client, modId);
|
||||
pluginData.state.serverLogs.log(LogType.MEMBER_KICK, {
|
||||
mod: userToConfigAccessibleUser(mod),
|
||||
user: userToConfigAccessibleUser(member.user),
|
||||
pluginData.getPlugin(LogsPlugin).logMemberKick({
|
||||
mod,
|
||||
user: member.user,
|
||||
caseNumber: createdCase.case_number,
|
||||
reason,
|
||||
reason: reason ?? "",
|
||||
});
|
||||
|
||||
pluginData.state.events.emit("kick", member.id, reason, kickOptions.isAutomodAction);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -5,6 +5,7 @@ import { LogType } from "../../../data/LogType";
|
|||
import { CasesPlugin } from "../../../plugins/Cases/CasesPlugin";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { formatReasonWithAttachments } from "./formatReasonWithAttachments";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
|
||||
export async function updateCase(pluginData, msg: Message, args) {
|
||||
let theCase: Case | undefined;
|
||||
|
@ -33,7 +34,7 @@ export async function updateCase(pluginData, msg: Message, args) {
|
|||
body: note,
|
||||
});
|
||||
|
||||
pluginData.state.serverLogs.log(LogType.CASE_UPDATE, {
|
||||
pluginData.getPlugin(LogsPlugin).logCaseUpdate({
|
||||
mod: msg.author,
|
||||
caseNumber: theCase.case_number,
|
||||
caseType: CaseTypes[theCase.type],
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { GuildMember, Snowflake } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { memberToConfigAccessibleMember, userToConfigAccessibleUser } from "../../../utils/configAccessibleObjects";
|
||||
import { memberToTemplateSafeMember, userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { renderTemplate } from "../../../templateFormatter";
|
||||
|
@ -9,6 +9,7 @@ import { waitForButtonConfirm } from "../../../utils/waitForInteraction";
|
|||
import { CasesPlugin } from "../../Cases/CasesPlugin";
|
||||
import { ModActionsPluginType, WarnOptions, WarnResult } from "../types";
|
||||
import { getDefaultContactMethods } from "./getDefaultContactMethods";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
|
||||
export async function warnMember(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
|
@ -24,7 +25,7 @@ export async function warnMember(
|
|||
guildName: pluginData.guild.name,
|
||||
reason,
|
||||
moderator: warnOptions.caseArgs?.modId
|
||||
? userToConfigAccessibleUser(await resolveUser(pluginData.client, warnOptions.caseArgs.modId))
|
||||
? userToTemplateSafeUser(await resolveUser(pluginData.client, warnOptions.caseArgs.modId))
|
||||
: {},
|
||||
});
|
||||
const contactMethods = warnOptions?.contactMethods
|
||||
|
@ -70,11 +71,11 @@ export async function warnMember(
|
|||
});
|
||||
|
||||
const mod = await pluginData.guild.members.fetch(modId as Snowflake);
|
||||
pluginData.state.serverLogs.log(LogType.MEMBER_WARN, {
|
||||
mod: memberToConfigAccessibleMember(mod),
|
||||
member: memberToConfigAccessibleMember(member),
|
||||
pluginData.getPlugin(LogsPlugin).logMemberWarn({
|
||||
mod,
|
||||
member,
|
||||
caseNumber: createdCase.case_number,
|
||||
reason,
|
||||
reason: reason ?? "",
|
||||
});
|
||||
|
||||
pluginData.state.events.emit("warn", member.id, reason, warnOptions.isAutomodAction);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue