Skip to content

Commit 2412549

Browse files
committed
Use configurable violation window in mod log and ban reason instead of hardcoded 30s
1 parent 9ee4d90 commit 2412549

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/modules/moderation/discordInvitesMonitor.listener.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ async function banForInviteSpam(
9797
.catch(() => {});
9898

9999
await message.guild.bans.create(member.user, {
100-
reason: `Auto-ban: Invite spam (${violation.count} violations across ${violation.channels.size} channel(s) in 30s)`,
100+
reason: `Auto-ban: Invite spam (${violation.count} violations across ${violation.channels.size} channel(s) in ${config.inviteSpam.violationWindowMs / 1000}s)`,
101101
deleteMessageSeconds: 604800,
102102
});
103103

@@ -106,6 +106,7 @@ async function banForInviteSpam(
106106
target: member.user,
107107
violationCount: violation.count,
108108
channelCount: violation.channels.size,
109+
violationWindowMs: config.inviteSpam.violationWindowMs,
109110
triggerReason,
110111
});
111112

src/modules/moderation/logs.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ interface InviteSpamBanLog {
121121
target: User;
122122
violationCount: number;
123123
channelCount: number;
124+
violationWindowMs: number;
124125
triggerReason: "same_channel" | "cross_channel";
125126
}
126127

@@ -194,7 +195,7 @@ const embedReasons: {
194195
`**New Score:** ${rep.newScore >= 0 ? "+" : ""}${rep.newScore}`,
195196

196197
InviteSpamBan: (ban) =>
197-
`**Violations:** ${ban.violationCount} in 30s\n` +
198+
`**Violations:** ${ban.violationCount} in ${ban.violationWindowMs / 1000}s\n` +
198199
`**Channels:** ${ban.channelCount}\n` +
199200
`**Trigger:** ${ban.triggerReason === "same_channel" ? "4+ violations in same channel" : "Violations across 3+ channels"}`,
200201
};
@@ -219,7 +220,8 @@ export async function logModerationAction(
219220
embed.setColor(embedColors[action.kind]);
220221

221222
const targetUser = await client.users.fetch(action.target).catch(() => null);
222-
const targetLabel = action.kind === "ReputationGranted" ? "Recipient" : "Offender";
223+
const targetLabel =
224+
action.kind === "ReputationGranted" ? "Recipient" : "Offender";
223225
let description = `**${targetLabel}**: ${targetUser && fakeMention(targetUser)} ${actualMention(action.target)}\n`;
224226
if ("reason" in action && action.reason) {
225227
description += `**Reason**: ${action.reason}\n`;

0 commit comments

Comments
 (0)