Delete any message with more than four attachments unless the author has the @Staff role, tell them privately why, and time out for ten minutes anyone who does it twice in a minute
Automatically removes messages containing more than 4 attachments to prevent spam. Staff members are exempt. If someone posts too many attachments twice within a minute, they receive a 10-minute timeout. All violators are notified privately via DM about why their message was removed.
Made by MEE6. Remix it to get a copy of your own and change anything you like.
⚠️ Your message was removed for having too many attachments (max 4 allowed). Please avoid spamming attachments.
⚠️ Your message was removed for having too many attachments (max 4). You have been timed out for 10 minutes due to repeated violations.
// Attachment spam filter: deletes messages with >4 attachments, times out repeat offenders
mee6.settings({
staff_role: { type: 'role', label: 'Staff role (exempt from filter)', sample: 'Staff' },
});
// Only messages with files wake the module
mee6.on('message', { hasAttachment: true }, async (ctx) => {
// Check if the message has more than 4 attachments
if (ctx.message.attachments.length <= 4) return;
// Exempt staff
const staffRoleId = ctx.settings.staff_role;
if (staffRoleId && ctx.author.roles.includes(staffRoleId)) return;
// Delete the message
await ctx.delete();
// Check if they did this recently (within the last 60 seconds)
const m = mee6.store.member(ctx.author.id);
const lastSpam = await m.get<number>('last_attachment_spam', 0);
const now = Math.floor(Date.now() / 1000);
if (now - lastSpam < 60) {
// Second offense within a minute: time out for 10 minutes
await mee6.timeout(ctx.author.id, 600, 'Attachment spam (repeated)');
await mee6.dm(
ctx.author.id,
'⚠️ Your message was removed for having too many attachments (max 4). You have been timed out for 10 minutes due to repeated violations.'
);
} else {
// First offense (or after cooldown): just warn
await mee6.dm(
ctx.author.id,
'⚠️ Your message was removed for having too many attachments (max 4 allowed). Please avoid spamming attachments.'
);
}
// Update the timestamp
await m.set('last_attachment_spam', now, { ttl: 60 });
});