Add /pingpanel which posts a panel with one button per role I choose in settings (three roles); pressing a button pings that role in the channel, each member can press a button only once every 30 minutes, and the ping is deleted after ten minutes
Ping Panel lets admins post a panel with buttons that ping specific roles. Each member can press each button once every 30 minutes, and the ping messages are automatically deleted after 10 minutes to keep the channel clean.
Usage:
/pingpanel to post the panelMade by MEE6. Remix it to get a copy of your own and change anything you like.
Ping Panel Click a button to ping the corresponding role. Each button has a 30-minute cooldown per member.
@Moderators — pinged by @Sam
@Moderators — pinged by @Jordan
// Ping panel: post a panel with buttons that ping configured roles, with cooldowns and auto-deletion
mee6.settings({
role1: { type: 'role', label: 'First role to ping', required: true, sample: 'Support' },
role2: { type: 'role', label: 'Second role to ping', required: true, sample: 'Moderators' },
role3: { type: 'role', label: 'Third role to ping', required: true, sample: 'Events' },
});
mee6.command('pingpanel', { description: 'Post the ping panel' }, async (ctx) => {
const role1 = ctx.settings.role1;
const role2 = ctx.settings.role2;
const role3 = ctx.settings.role3;
if (!role1 || !role2 || !role3) {
await ctx.reply('All three roles must be configured in the dashboard before posting the panel.');
return;
}
const roles = await mee6.listRoles();
const name = (id: string) => roles.find((r) => r.id === id)?.name ?? 'role';
await ctx.reply({
content:
'**Ping Panel**\nClick a button to ping the corresponding role. Each button has a 30-minute cooldown per member.',
buttons: [
{ label: `Ping ${name(role1)}`, customId: `ping_${role1}`, style: 'primary' },
{ label: `Ping ${name(role2)}`, customId: `ping_${role2}`, style: 'primary' },
{ label: `Ping ${name(role3)}`, customId: `ping_${role3}`, style: 'primary' },
],
});
});
mee6.on('button', async (ctx) => {
if (!ctx.customId.startsWith('ping_')) return;
const roleId = ctx.customId.replace('ping_', '');
const cooldownKey = `cd_ping_${roleId}`;
const m = mee6.store.member(ctx.author.id);
// Check cooldown (30 minutes = 1800 seconds)
const lastPing = await m.get<number>(cooldownKey, 0);
const now = Math.floor(Date.now() / 1000);
const cooldown = 1800;
if (now - lastPing < cooldown) {
const remaining = cooldown - (now - lastPing);
const minutes = Math.floor(remaining / 60);
const seconds = remaining % 60;
await ctx.reply({
content: `⏰ You can use this button again in ${minutes}m ${seconds}s.`,
ephemeral: true,
});
return;
}
// Post the ping
const sent = await ctx.send(ctx.message.channelId, {
content: `<@&${roleId}> — pinged by ${ctx.author.mention}`,
});
// Set cooldown
await m.set(cooldownKey, now, { ttl: cooldown });
// Schedule deletion after 10 minutes (600 seconds). A creation holds at
// most 25 schedules: past that, the ping simply stays.
try {
await mee6.schedule.once(`delete_${sent.messageId}`, 600, {
channelId: sent.channelId,
messageId: sent.messageId,
});
} catch (e) {
mee6.log(`Could not schedule the deletion of the ping: ${e}`);
}
await ctx.reply({
content: '✅ Role pinged! (The ping will be deleted in 10 minutes)',
ephemeral: true,
});
});
mee6.on('scheduled', async (ctx) => {
if (ctx.scheduleKey.startsWith('delete_')) {
const p = ctx.payload as { channelId: string; messageId: string };
await mee6.deleteMessage(p.channelId, p.messageId);
}
});