Every hour, purge the last 50 messages of a channel I choose and log how many were removed in #mod-logs, with /autopurge pause and /autopurge resume for the @Staff role
Auto-purge clears up to 50 messages from a chosen channel every hour and logs the results.
Configure three settings in the dashboard:
/autopurge resume — Start the hourly purge schedule (staff only)/autopurge pause — Stop the automatic purging (staff only)The purge runs every hour and logs how many messages were removed to your mod-logs channel.
Made by MEE6. Remix it to get a copy of your own and change anything you like.
⏸️ Auto-purge paused.
mee6.settings({
purge_channel: {
type: 'channel',
label: 'Channel to auto-purge',
required: true,
sample: 'spam',
},
log_channel: {
type: 'channel',
label: 'Where to log purges',
required: true,
sample: 'mod-logs',
},
staff_role: {
type: 'role',
label: 'Staff role (can pause/resume)',
required: true,
sample: 'Staff',
},
});
// Commands to pause/resume the purge schedule
mee6.command('autopurge pause', { description: 'Pause automatic purging' }, async (ctx) => {
if (!ctx.author.roles.includes(ctx.settings.staff_role)) {
await ctx.reply({ content: '❌ Only staff can pause auto-purge.', ephemeral: true });
return;
}
const cancelled = await mee6.schedule.cancel('hourly_purge');
if (cancelled) {
await ctx.reply('⏸️ Auto-purge paused.');
} else {
await ctx.reply({ content: 'Auto-purge is not running.', ephemeral: true });
}
});
mee6.command('autopurge resume', { description: 'Resume automatic purging' }, async (ctx) => {
if (!ctx.author.roles.includes(ctx.settings.staff_role)) {
await ctx.reply({ content: '❌ Only staff can resume auto-purge.', ephemeral: true });
return;
}
// Schedule the purge to run every hour (3600 seconds)
await mee6.schedule.every('hourly_purge', 3600, {
purgeChannelId: ctx.settings.purge_channel,
logChannelId: ctx.settings.log_channel,
});
await ctx.reply('▶️ Auto-purge resumed — will run every hour.');
});
// Scheduled event that performs the purge
mee6.on('scheduled', async (ctx) => {
if (ctx.scheduleKey !== 'hourly_purge') return;
const payload = ctx.payload as { purgeChannelId: string; logChannelId: string } | null;
if (!payload) return;
// Purge the last 50 messages from the configured channel
const deleted = await mee6.purge(payload.purgeChannelId, { limit: 50 });
// Log the result to the mod-logs channel
await ctx.send(payload.logChannelId, {
embed: {
title: '🧹 Auto-purge Complete',
description: `Removed **${deleted}** message${deleted === 1 ? '' : 's'} from <#${payload.purgeChannelId}>`,
color: '#5865f2',
footer: { text: new Date().toUTCString() },
},
});
});