Time out for 10 minutes anyone who posts the same message three times in a row
Automatically times out members who post the same message three times in a row.
Settings:
The creation tracks each member's last 3 messages and applies a timeout when all three are identical. Message history clears after 5 minutes of inactivity.
Made by MEE6. Remix it to get a copy of your own and change anything you like.
@Alex has been timed out for 10 minutes for spam.
// Time out members who post the same message three times in a row
mee6.settings({
timeout_minutes: {
type: 'integer',
label: 'Timeout duration (minutes)',
default: 10,
sample: 10,
},
exempt_role: {
type: 'role',
label: 'Exempt role (optional)',
sample: 'Staff',
},
});
mee6.on('message', async (ctx) => {
// Skip bots
if (ctx.author.bot) return;
// Skip if member has exempt role
const exemptRole = ctx.settings.exempt_role;
if (exemptRole && ctx.author.roles.includes(exemptRole)) return;
const userId = ctx.author.id;
const content = ctx.message.content.trim();
// Skip empty messages
if (!content) return;
// Get recent messages from this user
const m = mee6.store.member(userId);
const recent = await m.get<string[]>('recent_messages', []);
// Add current message
const updated = [...recent, content].slice(-3); // Keep last 3
await m.set('recent_messages', updated, { ttl: 300 }); // Clear after 5 min
// Check if last 3 messages are identical
if (updated.length === 3 && updated.every((msg) => msg === updated[0])) {
const minutes = ctx.settings.timeout_minutes || 10;
const seconds = minutes * 60;
try {
await mee6.timeout(userId, seconds, 'Posting the same message 3 times in a row');
await ctx.reply(`${ctx.author.mention} has been timed out for ${minutes} minutes for spam.`);
// Clear their message history so they don't get timed out again immediately
await m.delete('recent_messages');
} catch (error) {
mee6.log(`Failed to timeout ${userId}: ${error}`);
}
}
});