Add a /shift command that pays coins on a one-hour cooldown, and DM the member when their cooldown is over so they do not have to keep checking
A /shift command that pays coins on a cooldown and DMs members when they're ready to work again.
/shift — Earn coins (cooldown applies)The bot automatically DMs members when their cooldown expires so they don't have to keep checking.
Made by MEE6. Remix it to get a copy of your own and change anything you like.
💰 You earned 50 coins! I'll DM you when you can work again.
💰 You earned 50 coins! I'll DM you when you can work again.
💰 You earned 50 coins! I'll DM you when you can work again.
⏰ You need to rest! Come back in 60m 0s.
💰 You earned 50 coins! I'll DM you when you can work again.
// Work command with cooldown and DM notification
mee6.settings({
work_pay: { type: 'integer', label: 'Coins per work', default: 100, sample: 50 },
cooldown_hours: { type: 'integer', label: 'Cooldown (hours)', default: 1, sample: 1 },
});
/** Whether a call was refused because the member has left the server. */
function hasLeft(err: unknown): boolean {
return String(err).includes('is not in this server');
}
mee6.command('shift', { description: 'Earn coins (cooldown applies)' }, async (ctx) => {
const pay = ctx.settings.work_pay ?? 100;
const cooldownHours = ctx.settings.cooldown_hours ?? 1;
const cooldownSeconds = cooldownHours * 3600;
const m = mee6.store.member(ctx.author.id);
const lastWork = await m.get<number>('last_work', 0);
const now = Math.floor(Date.now() / 1000);
const elapsed = now - lastWork;
if (elapsed < cooldownSeconds) {
const remaining = cooldownSeconds - elapsed;
const minutes = Math.floor(remaining / 60);
const seconds = remaining % 60;
await ctx.reply(`⏰ You need to rest! Come back in ${minutes}m ${seconds}s.`);
return;
}
// Pay the member, raised by the server's Economy boosts like /work
const paid = await mee6.economy.add(ctx.author.id, pay, { boost: 'income' });
await m.set('last_work', now);
// Schedule a DM reminder when cooldown is over
await mee6.schedule.once(`work_ready_${ctx.author.id}`, cooldownSeconds, { userId: ctx.author.id, pay });
await ctx.reply(`💰 You earned **${paid.amount} coins**! I'll DM you when you can work again.`);
});
mee6.on('scheduled', async (ctx) => {
if (ctx.scheduleKey.startsWith('work_ready_')) {
const p = ctx.payload as { userId: string; pay: number } | null;
if (!p) return;
let sent: boolean;
try {
sent = await mee6.dm(p.userId, `✅ Your work cooldown is over! Use \`/shift\` to earn **${p.pay} coins** again.`);
} catch (err) {
// Nobody to remind: the member has left the server
if (!hasLeft(err)) throw err;
return;
}
if (!sent) {
mee6.log(`Could not DM user ${p.userId} — DMs are closed`);
}
}
});