Build a bank heist: /heist targets a member with coins, others join the crew with a button for two minutes, then the chance of success grows with the crew size, the loot is split between the crew or everybody pays a fine
A cooperative heist game where members team up to rob coins from another member.
How to play:
/heist @member to target someone with coins (minimum 100)Success mechanics:
Rewards & penalties:
One heist per channel at a time. Requires MEE6 Economy to be enabled.
Made by MEE6. Remix it to get a copy of your own and change anything you like.
3 members are planning to rob Jordan!
Click below to join the crew. The more members join, the higher the chance of success!
3
2m 0s
โ You joined the crew!
The crew of 3 successfully robbed Jordan!
๐ฐ 102 coins stolen and split among the crew. ๐ต Each member earned 34 coins.
65%
3
// Bank Heist โ assemble a crew and rob someone's coins!
interface Heist {
targetId: string;
targetName: string;
channelId: string;
crew: string[]; // member ids who joined
initiatorId: string;
endsAt: number; // timestamp in seconds
}
// A run makes 50 calls at most, and a failed heist costs two per member.
const MAX_CREW = 20;
/** 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(
'heist',
{
description: 'Start a bank heist on a member',
options: [{ name: 'target', type: 'user', description: 'Who to rob', required: true }],
},
async (ctx) => {
const targetId = ctx.option<string>('target');
// Can't rob yourself or a bot
if (targetId === ctx.author.id) {
await ctx.reply('You cannot rob yourself!');
return;
}
const target = await mee6.getMember(targetId);
if (!target) {
await ctx.reply('Target member not found.');
return;
}
if (target.bot) {
await ctx.reply('You cannot rob a bot!');
return;
}
// Check if target has coins
const targetBalance = await mee6.economy.balance(targetId);
if (targetBalance.coins < 100) {
await ctx.reply(`${target.displayName} doesn't have enough coins to rob (minimum 100).`);
return;
}
// Check for existing heist in this channel
const existingHeist = await mee6.store.get<Heist>(`heist_${ctx.channelId}`);
if (existingHeist) {
await ctx.reply('A heist is already in progress in this channel!');
return;
}
// Create the heist
const heist: Heist = {
targetId,
targetName: target.displayName,
channelId: ctx.channelId,
crew: [ctx.author.id],
initiatorId: ctx.author.id,
endsAt: Math.floor(Date.now() / 1000) + 120, // 2 minutes
};
await mee6.store.set(`heist_${ctx.channelId}`, heist, { ttl: 300 });
// Schedule the heist execution
await mee6.schedule.once(`heist_${ctx.channelId}`, 120, {
channelId: ctx.channelId,
});
await ctx.reply({
embed: {
title: '๐ฆ Bank Heist!',
description: `${ctx.author.displayName} is planning to rob **${target.displayName}** (${targetBalance.coins} coins)!\n\nClick below to join the crew. The more members join, the higher the chance of success!`,
color: '#e74c3c',
fields: [
{ name: 'Crew Size', value: '1', inline: true },
{ name: 'Time Left', value: '2 minutes', inline: true },
],
footer: { text: 'Success rate increases with crew size' },
},
buttons: [{ label: 'Join Crew', customId: 'join_heist', style: 'danger' }],
});
}
);
mee6.on('button', async (ctx) => {
if (ctx.customId === 'join_heist') {
const heist = await mee6.store.get<Heist>(`heist_${ctx.message.channelId}`);
if (!heist) {
await ctx.reply({ content: 'This heist has already ended!', ephemeral: true });
return;
}
// Can't join your own heist as target
if (ctx.author.id === heist.targetId) {
await ctx.reply({ content: 'You cannot join a heist against yourself!', ephemeral: true });
return;
}
// Check if already in crew
if (heist.crew.includes(ctx.author.id)) {
await ctx.reply({ content: 'You are already in the crew!', ephemeral: true });
return;
}
if (heist.crew.length >= MAX_CREW) {
await ctx.reply({ content: `The crew is full (${MAX_CREW} members)!`, ephemeral: true });
return;
}
// Add to crew
heist.crew.push(ctx.author.id);
await mee6.store.set(`heist_${ctx.message.channelId}`, heist, { ttl: 300 });
const timeLeft = Math.max(0, heist.endsAt - Math.floor(Date.now() / 1000));
const minutes = Math.floor(timeLeft / 60);
const seconds = timeLeft % 60;
const timeStr = minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`;
await ctx.editOriginal({
embed: {
title: '๐ฆ Bank Heist!',
description: `${heist.crew.length} members are planning to rob **${heist.targetName}**!\n\nClick below to join the crew. The more members join, the higher the chance of success!`,
color: '#e74c3c',
fields: [
{ name: 'Crew Size', value: `${heist.crew.length}`, inline: true },
{ name: 'Time Left', value: timeStr, inline: true },
],
footer: { text: 'Success rate increases with crew size' },
},
buttons: [{ label: 'Join Crew', customId: 'join_heist', style: 'danger' }],
});
await ctx.reply({ content: 'โ
You joined the crew!', ephemeral: true });
}
});
mee6.on('scheduled', async (ctx) => {
if (ctx.scheduleKey.startsWith('heist_')) {
const payload = ctx.payload as { channelId: string };
const heist = await mee6.store.get<Heist>(`heist_${payload.channelId}`);
if (!heist) return; // Heist was cancelled or already executed
const crewSize = heist.crew.length;
// Success rate: 20% base + 15% per crew member (caps at 95% with 5 members)
const successRate = Math.min(95, 20 + crewSize * 15);
const roll = Math.random() * 100;
const success = roll < successRate;
const targetBalance = await mee6.economy.balance(heist.targetId);
// The heist is over whatever happens next: it never pays out twice.
await mee6.store.delete(`heist_${payload.channelId}`);
if (success) {
// Calculate loot (30% of target's balance, minimum 100)
const sharePerMember = Math.floor(Math.max(100, Math.floor(targetBalance.coins * 0.3)) / crewSize);
// Pay the crew, then take from the target only what was paid: the share
// of a member who has left the server stays with the target.
let paid = 0;
for (const memberId of heist.crew) {
try {
await mee6.economy.add(memberId, sharePerMember);
paid++;
} catch (err) {
if (!hasLeft(err)) throw err;
}
}
const loot = sharePerMember * paid;
if (loot > 0) await mee6.economy.remove(heist.targetId, loot);
await ctx.send(payload.channelId, {
embed: {
title: '๐ Heist Successful!',
description: `The crew of ${crewSize} successfully robbed **${
heist.targetName
}**!\n\n๐ฐ **${loot} coins** stolen and split among ${
paid === crewSize ? 'the crew' : `the ${paid} still in the server`
}.\n๐ต Each member earned **${sharePerMember} coins**.`,
color: '#2ecc71',
fields: [
{ name: 'Success Rate', value: `${successRate}%`, inline: true },
{ name: 'Crew Size', value: `${crewSize}`, inline: true },
],
},
});
} else {
// Heist failed - crew pays fine
const finePerMember = Math.min(50, Math.floor((targetBalance.coins * 0.1) / crewSize));
for (const memberId of heist.crew) {
const memberBalance = await mee6.economy.balance(memberId);
if (memberBalance.coins >= finePerMember) {
await mee6.economy.remove(memberId, finePerMember);
}
}
await ctx.send(payload.channelId, {
embed: {
title: 'โ Heist Failed!',
description: `The crew of ${crewSize} was caught trying to rob **${heist.targetName}**!\n\nโ๏ธ Each crew member paid a **${finePerMember} coin** fine.`,
color: '#e74c3c',
fields: [
{ name: 'Success Rate', value: `${successRate}%`, inline: true },
{ name: 'Crew Size', value: `${crewSize}`, inline: true },
],
},
});
}
}
});