Build an idle business: /shack shows your shop and its hourly income, /collect cashes what accrued since the last collection, /hire and /upgrade raise the income for coins, and /shacks ranks the richest shops
Build your shack empire! Hire workers to generate passive income, upgrade for bonuses, and climb the leaderboard.
Commands:
/shack — View your shop stats and pending earnings/collect — Cash in your accumulated coins/hire — Hire a worker for 100 coins (increases hourly income by 10)/upgrade — Boost income by 50% per level for 150 coins/shacks — See the top earners leaderboardYour shack earns coins every hour based on workers × upgrades. Collect anytime to cash in!
Made by MEE6. Remix it to get a copy of your own and change anything you like.
👷 Hired a worker! You now have 1 workers earning 10 coins/hour.
👷 Hired a worker! You now have 2 workers earning 20 coins/hour.
210 coins
0 coins
20 coins/hour
2
0
0 coins
⏰ Nothing to collect yet! Hire workers with /hire to start earning.
💰 Collected 60 coins! Your shack keeps working.
⚡ Upgraded to level 1! Your income is now 30 coins/hour (+50% per level).
120 coins
0 coins
30 coins/hour
2
1
60 coins
👷 Hired a worker! You now have 1 workers earning 10 coins/hour.
❌ You need 100 coins to hire a worker. You have 80.
❌ Hire at least one worker before upgrading!
1. Alex — 60 coins earned 2. You — 0 coins earned
// Idle Shack — run a business, collect earnings, upgrade and compete
interface ShackData {
workers: number;
upgradeLevel: number;
lastCollect: number;
totalEarned: number;
// Earnings left over when a collection reached its cap (absent on older shacks)
unpaid?: number;
}
const WORKER_COST = 100;
const UPGRADE_COST = 150;
const BASE_INCOME = 10; // per worker per hour
const UPGRADE_MULTIPLIER = 1.5;
// A call moves at most 1,000,000,000 coins, the Economy plugin's own balance
// cap: so does a collection — the rest waits for the next one.
const MAX_COLLECT = 1_000_000_000;
function getShack(m: any): ShackData {
return m.get<ShackData>('shack', {
workers: 0,
upgradeLevel: 0,
lastCollect: Math.floor(Date.now() / 1000),
totalEarned: 0,
});
}
function calculateIncome(shack: ShackData): number {
if (shack.workers === 0) return 0;
const multiplier = Math.pow(UPGRADE_MULTIPLIER, shack.upgradeLevel);
return Math.floor(shack.workers * BASE_INCOME * multiplier);
}
function calculatePending(shack: ShackData): number {
const now = Math.floor(Date.now() / 1000);
const hoursPassed = (now - shack.lastCollect) / 3600;
const hourlyIncome = calculateIncome(shack);
return (shack.unpaid ?? 0) + Math.floor(hoursPassed * hourlyIncome);
}
/** Pay `amount` coins, raised by the server's Economy boosts like /work;
* returns what was credited. */
async function pay(userId: string, amount: number): Promise<number> {
if (amount <= 0) return 0;
return (await mee6.economy.add(userId, amount, { boost: 'income' })).amount;
}
/**
* Settle the pending earnings against `cost` (0 for a plain collection): the
* coins move once — the cost taken from the balance when the earnings fall
* short, what is left of them paid otherwise, up to MAX_COLLECT. Returns the
* earnings collected; what is over the cap stays on the shack as `unpaid`.
* The shack is restarted from now, and saved by the caller.
*/
async function settle(userId: string, shack: ShackData, cost: number): Promise<number> {
const pending = calculatePending(shack);
const owed = pending - cost;
// What a running Economy boost added to the earnings paid
let bonus = 0;
if (owed < 0) {
await mee6.economy.remove(userId, -owed);
shack.unpaid = 0;
} else {
const paid = Math.min(owed, MAX_COLLECT);
bonus = (await pay(userId, paid)) - paid;
shack.unpaid = owed - paid;
}
const collected = pending - (shack.unpaid ?? 0) + bonus;
shack.totalEarned += collected;
shack.lastCollect = Math.floor(Date.now() / 1000);
return collected;
}
mee6.command('shack', { description: 'View your shack and income stats' }, async (ctx) => {
const m = mee6.store.member(ctx.author.id);
const shack = await getShack(m);
const balance = await mee6.economy.balance(ctx.author.id);
const hourlyIncome = calculateIncome(shack);
const pending = calculatePending(shack);
await ctx.reply({
embed: {
title: `🏚️ ${ctx.author.displayName}'s Shack`,
color: '#8B4513',
fields: [
{ name: '💰 Balance', value: `${balance.coins} coins`, inline: true },
{ name: '⏰ Pending', value: `${pending} coins`, inline: true },
{ name: '📈 Hourly Income', value: `${hourlyIncome} coins/hour`, inline: true },
{ name: '👷 Workers', value: `${shack.workers}`, inline: true },
{ name: '⚡ Upgrade Level', value: `${shack.upgradeLevel}`, inline: true },
{ name: '🏆 Total Earned', value: `${shack.totalEarned} coins`, inline: true },
],
footer: { text: 'Use /collect to cash in your earnings!' },
},
});
});
mee6.command('collect', { description: 'Collect your pending earnings' }, async (ctx) => {
const m = mee6.store.member(ctx.author.id);
const shack = await getShack(m);
const pending = calculatePending(shack);
if (pending === 0) {
await ctx.reply('⏰ Nothing to collect yet! Hire workers with `/hire` to start earning.');
return;
}
// The coins are paid before the shack is restarted: a payment that fails
// leaves the earnings where they were.
const collected = await settle(ctx.author.id, shack, 0);
await m.set('shack', shack);
await m.set('total_earned', shack.totalEarned); // For leaderboard
const left = shack.unpaid ? ` **${shack.unpaid} coins** are still waiting: \`/collect\` again.` : '';
await ctx.reply(`💰 Collected **${collected} coins**! Your shack keeps working.${left}`);
});
mee6.command('hire', { description: 'Hire a worker to increase income (100 coins)' }, async (ctx) => {
const m = mee6.store.member(ctx.author.id);
const balance = await mee6.economy.balance(ctx.author.id);
const shack = await getShack(m);
// Pending earnings count toward the cost
if (balance.coins + calculatePending(shack) < WORKER_COST) {
await ctx.reply(`❌ You need **${WORKER_COST} coins** to hire a worker. You have ${balance.coins}.`);
return;
}
// Collect pending earnings before changing the rate, and pay the worker
const pending = await settle(ctx.author.id, shack, WORKER_COST);
shack.workers += 1;
await m.set('shack', shack);
await m.set('total_earned', shack.totalEarned); // For leaderboard
const newIncome = calculateIncome(shack);
await ctx.reply(
`👷 Hired a worker! You now have **${shack.workers} workers** earning **${newIncome} coins/hour**.` +
(pending > 0 ? ` (Also collected ${pending} pending coins)` : '')
);
});
mee6.command('upgrade', { description: 'Upgrade your shack to boost income (150 coins)' }, async (ctx) => {
const m = mee6.store.member(ctx.author.id);
const balance = await mee6.economy.balance(ctx.author.id);
const shack = await getShack(m);
if (shack.workers === 0) {
await ctx.reply('❌ Hire at least one worker before upgrading!');
return;
}
// Pending earnings count toward the cost
if (balance.coins + calculatePending(shack) < UPGRADE_COST) {
await ctx.reply(`❌ You need **${UPGRADE_COST} coins** to upgrade. You have ${balance.coins}.`);
return;
}
// Collect pending earnings before changing the rate, and pay the upgrade
const pending = await settle(ctx.author.id, shack, UPGRADE_COST);
shack.upgradeLevel += 1;
await m.set('shack', shack);
await m.set('total_earned', shack.totalEarned); // For leaderboard
const newIncome = calculateIncome(shack);
const boost = Math.floor((UPGRADE_MULTIPLIER - 1) * 100);
await ctx.reply(
`⚡ Upgraded to level **${shack.upgradeLevel}**! Your income is now **${newIncome} coins/hour** (+${boost}% per level).` +
(pending > 0 ? ` (Also collected ${pending} pending coins)` : '')
);
});
mee6.command('shacks', { description: 'View the richest shacks leaderboard' }, async (ctx) => {
const top = await mee6.store.memberTop('total_earned', 10);
if (top.length === 0) {
await ctx.reply('🏚️ No shacks yet! Be the first with `/hire`.');
return;
}
const lines = await Promise.all(
top.map(async (entry, i) => {
const member = await mee6.getMember(entry.user_id);
const name = member ? member.displayName : 'Unknown';
return `**${i + 1}.** ${name} — ${entry.value} coins earned`;
})
);
await ctx.reply({
embed: {
title: '🏆 Top Shacks',
description: lines.join('\n'),
color: '#FFD700',
footer: { text: 'Ranked by total earnings' },
},
});
});