Add a /purge command, restricted to the @Staff role, that deletes the last N messages of the channel and confirms privately how many it removed
Bulk delete messages in a channel, restricted to staff.
Usage: /purge count:50
Requirements:
How it works:
/purge with a countThe reply is ephemeral (only visible to you), so it doesn't clutter the channel.
Made by MEE6. Remix it to get a copy of your own and change anything you like.
This is the start of the #general channel.
// Purge command - deletes messages in bulk, restricted to staff
mee6.settings({
staff_role: {
type: 'role',
label: 'Staff role (who can purge)',
required: true,
sample: 'Staff',
},
});
mee6.command(
'purge',
{
description: 'Delete recent messages',
ephemeral: true,
options: [
{
name: 'count',
type: 'integer',
description: 'Number of messages to delete (1-100)',
required: true,
},
],
},
async (ctx) => {
const staffRoleId = ctx.settings.staff_role;
// Check if staff role is configured
if (!staffRoleId) {
await ctx.reply('No staff role configured. Ask an admin to set it in the dashboard.');
return;
}
// Check if user has the staff role
if (!ctx.author.roles.includes(staffRoleId)) {
await ctx.reply('You need the staff role to use this command.');
return;
}
const count = ctx.option<number>('count');
// Validate count
if (count < 1 || count > 100) {
await ctx.reply('Count must be between 1 and 100.');
return;
}
// Purge messages
const deleted = await mee6.purge(ctx.channelId, { limit: count });
await ctx.reply(`✅ Deleted ${deleted} message${deleted === 1 ? '' : 's'}.`);
}
);