Every Saturday at 6pm UTC a boss with 10,000 HP appears in a channel I choose, members hit it with an Attack button on a 60-second cooldown, damage is tracked per member, and when it dies the top three damage dealers get coins
A weekly boss raid
Made by MEE6. Remix it to get a copy of your own and change anything you like.
โ Weekly boss will spawn every Saturday at 6pm UTC!
โ Boss spawned!
// Weekly Boss Battle โ every Saturday at 6pm UTC, a boss spawns with 10,000 HP.
// Members attack it with a 60-second cooldown, damage is tracked, and the top 3 get coin rewards.
mee6.settings({
channel: { type: 'channel', label: 'Boss battle channel', required: true, sample: 'announcements' },
first_prize: { type: 'integer', label: 'Coins for 1st place', default: 500, sample: 500 },
second_prize: { type: 'integer', label: 'Coins for 2nd place', default: 300, sample: 300 },
third_prize: { type: 'integer', label: 'Coins for 3rd place', default: 100, sample: 100 },
});
// A call moves at most 1,000,000,000 coins, the Economy plugin's own balance
// cap: so does a prize.
const MAX_PRIZE = 1_000_000_000;
/** 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');
}
interface BossState {
hp: number;
maxHp: number;
messageId: string;
channelId: string;
damage: Record<string, number>; // userId -> total damage
startedAt: number;
}
// Schedule the weekly boss spawn โ recreate the schedule on setup
mee6.command('boss setup', { description: 'Set up the weekly boss schedule (admin)' }, async (ctx) => {
await mee6.schedule.cron('weekly_boss', '0 18 * * 6', { channelId: ctx.settings.channel });
await ctx.reply('โ
Weekly boss will spawn every Saturday at 6pm UTC!');
});
// Manual spawn for testing
mee6.command('boss spawn', { description: 'Spawn a boss now (admin)' }, async (ctx) => {
const channelId = ctx.settings.channel;
if (!channelId) {
await ctx.reply('โ No boss channel is set โ an admin can choose one in the dashboard.');
return;
}
await spawnBoss(channelId, ctx);
await ctx.reply({ content: 'โ
Boss spawned!', ephemeral: true });
});
// Check current boss stats
mee6.command('boss stats', { description: 'View the current boss status' }, async (ctx) => {
const boss = await mee6.store.get<BossState>('current_boss');
if (!boss) {
await ctx.reply('No boss is active right now. The next one spawns Saturday at 6pm UTC!');
return;
}
const sorted = Object.entries(boss.damage).sort(([, a], [, b]) => b - a);
const top5 = sorted.slice(0, 5).map(([uid, dmg], i) => `${i + 1}. <@${uid}> โ ${dmg.toLocaleString()} damage`);
await ctx.reply({
embed: {
title: '๐ Boss Battle',
description: `**HP:** ${boss.hp.toLocaleString()} / ${boss.maxHp.toLocaleString()}\n\n**Top Damage Dealers:**\n${
top5.join('\n') || 'No attacks yet!'
}`,
color: boss.hp > 0 ? 0xe74c3c : 0x2ecc71,
},
});
});
// The scheduled event that spawns the boss
mee6.on('scheduled', async (ctx) => {
if (ctx.scheduleKey === 'weekly_boss') {
const p = ctx.payload as { channelId: string } | null;
const channelId = p?.channelId;
if (!channelId) return;
await spawnBoss(channelId, ctx);
}
});
async function spawnBoss(channelId: string, ctx: any) {
const boss: BossState = {
hp: 10000,
maxHp: 10000,
messageId: '',
channelId,
damage: {},
startedAt: Date.now(),
};
const sent = await ctx.send(channelId, {
content: '๐จ **A WILD BOSS HAS APPEARED!** ๐จ',
embed: {
title: '๐ Weekly Boss Battle',
description: `**HP:** 10,000 / 10,000\n\nAttack the boss and deal damage! Top 3 damage dealers win coins when it dies.`,
color: 0xe74c3c,
},
buttons: [{ label: 'โ๏ธ Attack', customId: 'boss_attack', style: 'danger' }],
});
boss.messageId = sent.messageId;
await mee6.store.set('current_boss', boss);
}
// Handle attacks
mee6.on('button', async (ctx) => {
if (ctx.customId !== 'boss_attack') return;
const boss = await mee6.store.get<BossState>('current_boss');
if (!boss || boss.hp <= 0) {
await ctx.reply({ content: 'โ No boss is active right now!', ephemeral: true });
return;
}
// Check cooldown (60 seconds)
const m = mee6.store.member(ctx.author.id);
const lastAttack = await m.get<number>('boss_attack_cd', 0);
const now = Math.floor(Date.now() / 1000);
const cooldown = 60;
if (now - lastAttack < cooldown) {
const remaining = cooldown - (now - lastAttack);
await ctx.reply({ content: `โฐ Cooldown! Wait ${remaining}s before attacking again.`, ephemeral: true });
return;
}
// Deal damage (random between 50-150)
const damage = Math.floor(Math.random() * 101) + 50;
boss.hp = Math.max(0, boss.hp - damage);
boss.damage[ctx.author.id] = (boss.damage[ctx.author.id] || 0) + damage;
await m.set('boss_attack_cd', now);
// Update the boss message
const hpBar = createHpBar(boss.hp, boss.maxHp);
const sorted = Object.entries(boss.damage).sort(([, a], [, b]) => b - a);
const top3 = sorted.slice(0, 3).map(([uid, dmg], i) => `${i + 1}. <@${uid}> โ ${dmg.toLocaleString()}`);
if (boss.hp <= 0) {
// Boss defeated! It leaves the store before anything else: a step that
// fails below must not leave it there to be defeated, and paid, again
await mee6.store.delete('current_boss');
await ctx.editOriginal({
content: '๐ **THE BOSS HAS BEEN DEFEATED!** ๐',
embed: {
title: '๐ Boss Defeated!',
description: `${hpBar}\n\n**Top Damage Dealers:**\n${top3.join('\n')}\n\n**Rewards distributed!**`,
color: 0x2ecc71,
footer: { text: `Defeated after ${Math.round((Date.now() - boss.startedAt) / 60000)} minutes` },
},
buttons: [],
});
// Distribute rewards
const prizes = [ctx.settings.first_prize, ctx.settings.second_prize, ctx.settings.third_prize];
for (let i = 0; i < Math.min(3, sorted.length); i++) {
const [userId] = sorted[i];
// A prize set to nothing is skipped, one above the cap paid the cap
const prize = Math.min(Math.floor(prizes[i] ?? 0), MAX_PRIZE);
if (prize <= 0) continue;
try {
// The prize follows the server's Economy boosts like /work
await mee6.economy.add(userId, prize, { boost: 'income' });
} catch (err) {
// A member who left after attacking forfeits the prize; the others are paid
if (!hasLeft(err)) throw err;
}
}
await ctx.reply({ content: `๐ฅ You dealt ${damage} damage! The boss is defeated!`, ephemeral: true });
} else {
// Boss still alive
await mee6.store.set('current_boss', boss);
await ctx.editOriginal({
embed: {
title: '๐ Weekly Boss Battle',
description: `${hpBar}\n\n**Top Damage Dealers:**\n${top3.join('\n') || 'No attacks yet!'}`,
color: 0xe74c3c,
},
});
await ctx.reply({ content: `โ๏ธ You dealt ${damage} damage!`, ephemeral: true });
}
});
function createHpBar(current: number, max: number): string {
const pct = Math.max(0, current / max);
const filled = Math.round(pct * 20);
const empty = 20 - filled;
const bar = 'โ'.repeat(filled) + 'โ'.repeat(empty);
return `**HP:** ${current.toLocaleString()} / ${max.toLocaleString()}\n\`${bar}\` ${Math.round(pct * 100)}%`;
}