Catch image-spam automatically
const key = `imgspam.${ctx.message.authorId}`;
const now = Date.now();
const recent = JSON.parse(getKV(key) || "[]")
.filter(e => now - e.timestamp < 10000);
recent.push({
messageId: ctx.message.id,
channelId: ctx.message.channelId,
timestamp: now
});
setKV(key, JSON.stringify(recent), 60);
if (recent.length >= 3 && ctx.message.attachments.length > 0) {
deleteKV(key);
timeout(ctx.message.authorId, "Image spam (3+ attachments in 10s)", 1440);
const links = recent
.map(e => `https://discord.com/channels/${ctx.guildId}/${e.channelId}/${e.messageId}`)
.join("\n");
sendMessage(ctx.env.mod_alert_channel_id, "", [{
title: "🖼️ Image spam",
description: `<@${ctx.message.authorId}> timed out 24h. Please review:\n${links}`,
colorArgb: 15105570
}]);
}