Add /pling which adds one coin to a swear jar and replies with the total, /jar which shows it and who paid the most, and /jar reset for the @Staff role
A simple swear jar system where members add coins with /pling when they slip up. Use /jar view to see the total and who paid the most. Staff can reset the jar with /jar reset to start fresh.
Made by MEE6. Remix it to get a copy of your own and change anything you like.
🪙 Pling! The jar now has 1 coin.
🪙 Pling! The jar now has 2 coins.
🪙 Pling! The jar now has 3 coins.
🪙 Pling! The jar now has 4 coins.
🪙 Pling! The jar now has 5 coins.
The jar contains 5 coins.
Top contributors:
@Alex: 2 coins @Sam: 2 coins @You: 1 coin❌ Only staff can reset the jar.
✅ The jar has been reset! Collected 5 coins.
// Swear jar — members add coins and admins can reset it
mee6.settings({
staff_role: { type: 'role', label: 'Staff role (can reset the jar)', sample: 'Staff' },
});
// Contributions are kept under a key that carries the jar's epoch, so a
// reset is one increment rather than a walk over every contributor (a run
// may make 50 SDK calls, a popular jar has more members than that).
async function paidKey(): Promise<string> {
const epoch = await mee6.store.get<number>('jar_epoch', 0);
return `jar_paid_${epoch}`;
}
// Add a coin to the jar
mee6.command('pling', { description: 'Add a coin to the swear jar' }, async (ctx) => {
const m = mee6.store.member(ctx.author.id);
const total = await mee6.store.incr('jar_total');
await m.incr(await paidKey());
await ctx.reply(`🪙 **Pling!** The jar now has **${total}** coin${total === 1 ? '' : 's'}.`);
});
// View the jar total and leaderboard
mee6.command('jar view', { description: 'View the swear jar' }, async (ctx) => {
const total = await mee6.store.get<number>('jar_total', 0);
const top = await mee6.store.memberTop(await paidKey(), 5);
let leaderboard = '';
if (top.length > 0) {
leaderboard = '\n\n**Top contributors:**\n';
for (let i = 0; i < top.length; i++) {
leaderboard += `${i + 1}. <@${top[i].user_id}>: ${top[i].value} coin${top[i].value === 1 ? '' : 's'}\n`;
}
}
await ctx.reply({
embed: {
title: '🪙 Swear Jar',
description: `The jar contains **${total}** coin${total === 1 ? '' : 's'}.${leaderboard}`,
color: '#f39c12',
},
});
});
// Reset the jar (staff only)
mee6.command('jar reset', { description: 'Reset the swear jar (staff only)' }, async (ctx) => {
const staffRole = ctx.settings.staff_role;
if (!staffRole) {
await ctx.reply('⚠️ No staff role is configured — an admin can set one in the dashboard.');
return;
}
if (!ctx.author.roles.includes(staffRole)) {
await ctx.reply('❌ Only staff can reset the jar.');
return;
}
const total = await mee6.store.get<number>('jar_total', 0);
await mee6.store.set('jar_total', 0);
// Clear every contribution at once: a new epoch, a fresh key.
await mee6.store.incr('jar_epoch');
await ctx.reply(`✅ The jar has been reset! Collected **${total}** coin${total === 1 ? '' : 's'}.`);
});