Build clans: /clan create names one, /clan invite and /clan join add members, /clan deposit pays coins into a shared bank, /clan upgrade spends the bank on a level, and /clans ranks the clans by level and bank
Clans lets members form groups with shared banks and competitive upgrades.
/clan create <name> — Found a new clan/clan invite @user — Invite someone to your clan (expires in 1 hour)/clan join — Accept a pending invitation/clan deposit <amount> — Add coins to your clan's bank/clan upgrade — Spend bank coins to level up (owner only)/clan info — View your clan's stats/clans — See the leaderboard ranked by level and bankEach clan has a shared bank that members deposit into. The owner can spend the bank to upgrade the clan's level. Upgrade costs increase with level: L1→2 costs 300 coins, L2→3 costs 600, and so on. Clans compete on the leaderboard, sorted by level first, then bank size.
Made by MEE6. Remix it to get a copy of your own and change anything you like.
Dragon Knights has been founded!
@Alex
1
0 coins
Invited @Sam to Dragon Knights! They have 1 hour to accept with /clan join.
Welcome to Dragon Knights!
2
1
0 coins
Deposited 300 coins into Dragon Knights
300 coins
110 coins
Deposited 50 coins into Dragon Knights
350 coins
45 coins
@Alex
1
350 coins
@Alex, @Sam
300 coins (0 needed)
Dragon Knights is now level 2!
300 coins
50 coins
600 coins
Phoenix Rising has been founded!
@Jordan
1
0 coins
Deposited 200 coins into Phoenix Rising
200 coins
140 coins
🥇 Dragon Knights — Level 2 • 50 coins • 2 members 🥈 Phoenix Rising — Level 1 • 200 coins • 1 members
// Clan system with shared banks, upgrades, and leaderboards
interface Clan {
name: string;
owner: string;
members: string[];
bank: number;
level: number;
createdAt: number;
}
// Helper to get all clans
async function getAllClans(): Promise<Record<string, Clan>> {
return (await mee6.store.get<Record<string, Clan>>('clans')) ?? {};
}
// Helper to save all clans
async function saveClans(clans: Record<string, Clan>): Promise<void> {
await mee6.store.set('clans', clans);
}
// Helper to get a member's clan
async function getMemberClan(userId: string): Promise<{ id: string; clan: Clan } | null> {
const clans = await getAllClans();
for (const [id, clan] of Object.entries(clans)) {
if (clan.members.includes(userId)) {
return { id, clan };
}
}
return null;
}
// Helper to calculate upgrade cost
function getUpgradeCost(level: number): number {
return 300 * level; // Level 1→2 costs 300, 2→3 costs 600, etc.
}
mee6.command(
'clan create',
{
description: 'Create a new clan',
options: [{ name: 'name', type: 'string', description: 'Clan name', required: true }],
},
async (ctx) => {
const clanName = ctx.option<string>('name').trim();
if (!clanName || clanName.length < 2 || clanName.length > 32) {
await ctx.reply('Clan name must be 2-32 characters.');
return;
}
// Check if member is already in a clan
const existing = await getMemberClan(ctx.author.id);
if (existing) {
await ctx.reply(`You're already in **${existing.clan.name}**. Leave it first.`);
return;
}
const clans = await getAllClans();
// Check if clan name is already taken
const nameTaken = Object.values(clans).some((c) => c.name.toLowerCase() === clanName.toLowerCase());
if (nameTaken) {
await ctx.reply(`A clan named **${clanName}** already exists.`);
return;
}
// Create the clan
const clanId = `clan_${Date.now()}_${ctx.author.id}`;
clans[clanId] = {
name: clanName,
owner: ctx.author.id,
members: [ctx.author.id],
bank: 0,
level: 1,
createdAt: Date.now(),
};
await saveClans(clans);
await ctx.reply({
embed: {
title: '🏰 Clan Created!',
description: `**${clanName}** has been founded!`,
fields: [
{ name: 'Founder', value: ctx.author.mention, inline: true },
{ name: 'Level', value: '1', inline: true },
{ name: 'Bank', value: '0 coins', inline: true },
],
color: '#3498db',
},
});
}
);
mee6.command(
'clan invite',
{
description: 'Invite a member to your clan',
options: [{ name: 'user', type: 'user', description: 'Member to invite', required: true }],
},
async (ctx) => {
const targetId = ctx.option<string>('user');
if (targetId === ctx.author.id) {
await ctx.reply('You cannot invite yourself.');
return;
}
// Check if inviter is in a clan
const myClan = await getMemberClan(ctx.author.id);
if (!myClan) {
await ctx.reply('You are not in a clan. Create one with `/clan create`.');
return;
}
// Check if target is already in a clan
const targetClan = await getMemberClan(targetId);
if (targetClan) {
await ctx.reply(`<@${targetId}> is already in **${targetClan.clan.name}**.`);
return;
}
// Store the invitation
const m = mee6.store.member(targetId);
await m.set(
'clan_invite',
{ clanId: myClan.id, clanName: myClan.clan.name, inviter: ctx.author.id },
{ ttl: 3600 }
);
await ctx.reply(
`Invited <@${targetId}> to **${myClan.clan.name}**! They have 1 hour to accept with \`/clan join\`.`
);
}
);
mee6.command(
'clan join',
{
description: 'Join a clan you were invited to',
},
async (ctx) => {
// Check if member is already in a clan
const existing = await getMemberClan(ctx.author.id);
if (existing) {
await ctx.reply(`You're already in **${existing.clan.name}**.`);
return;
}
// Check for an invitation
const m = mee6.store.member(ctx.author.id);
const invite = await m.get<{ clanId: string; clanName: string; inviter: string }>('clan_invite');
if (!invite) {
await ctx.reply('You have no pending clan invitations.');
return;
}
// Add member to the clan
const clans = await getAllClans();
const clan = clans[invite.clanId];
if (!clan) {
await ctx.reply('That clan no longer exists.');
await m.delete('clan_invite');
return;
}
clan.members.push(ctx.author.id);
await saveClans(clans);
await m.delete('clan_invite');
await ctx.reply({
embed: {
title: '🏰 Joined Clan!',
description: `Welcome to **${clan.name}**!`,
fields: [
{ name: 'Members', value: `${clan.members.length}`, inline: true },
{ name: 'Level', value: `${clan.level}`, inline: true },
{ name: 'Bank', value: `${clan.bank} coins`, inline: true },
],
color: '#2ecc71',
},
});
}
);
mee6.command(
'clan deposit',
{
description: 'Deposit coins into your clan bank',
options: [{ name: 'amount', type: 'integer', description: 'Coins to deposit', required: true }],
},
async (ctx) => {
const amount = ctx.option<number>('amount');
if (amount <= 0) {
await ctx.reply('Amount must be positive.');
return;
}
// Check if member is in a clan
const myClan = await getMemberClan(ctx.author.id);
if (!myClan) {
await ctx.reply('You are not in a clan.');
return;
}
// Check member's balance
const balance = await mee6.economy.balance(ctx.author.id);
if (balance.coins < amount) {
await ctx.reply(`You only have ${balance.coins} coins.`);
return;
}
// Transfer coins
await mee6.economy.remove(ctx.author.id, amount);
const clans = await getAllClans();
clans[myClan.id].bank += amount;
await saveClans(clans);
await ctx.reply({
embed: {
title: '💰 Deposit Successful',
description: `Deposited **${amount} coins** into **${myClan.clan.name}**`,
fields: [
{ name: 'Clan Bank', value: `${clans[myClan.id].bank} coins`, inline: true },
{ name: 'Your Balance', value: `${balance.coins - amount} coins`, inline: true },
],
color: '#f39c12',
},
});
}
);
mee6.command(
'clan upgrade',
{
description: 'Upgrade your clan using the bank',
},
async (ctx) => {
// Check if member is in a clan
const myClan = await getMemberClan(ctx.author.id);
if (!myClan) {
await ctx.reply('You are not in a clan.');
return;
}
// Only owner can upgrade
if (myClan.clan.owner !== ctx.author.id) {
await ctx.reply('Only the clan owner can upgrade.');
return;
}
const cost = getUpgradeCost(myClan.clan.level);
if (myClan.clan.bank < cost) {
await ctx.reply({
embed: {
title: '❌ Insufficient Funds',
description: `Level **${myClan.clan.level} → ${myClan.clan.level + 1}** costs **${cost} coins**`,
fields: [
{ name: 'Clan Bank', value: `${myClan.clan.bank} coins`, inline: true },
{ name: 'Need', value: `${cost - myClan.clan.bank} more coins`, inline: true },
],
color: '#e74c3c',
},
});
return;
}
// Upgrade the clan
const clans = await getAllClans();
clans[myClan.id].bank -= cost;
clans[myClan.id].level += 1;
await saveClans(clans);
await ctx.reply({
embed: {
title: '⬆️ Clan Upgraded!',
description: `**${myClan.clan.name}** is now level **${clans[myClan.id].level}**!`,
fields: [
{ name: 'Cost', value: `${cost} coins`, inline: true },
{ name: 'Bank Remaining', value: `${clans[myClan.id].bank} coins`, inline: true },
{ name: 'Next Upgrade', value: `${getUpgradeCost(clans[myClan.id].level)} coins`, inline: true },
],
color: '#9b59b6',
},
});
}
);
mee6.command(
'clans',
{
description: 'View the clan leaderboard',
},
async (ctx) => {
const clans = await getAllClans();
const clanList = Object.values(clans);
if (clanList.length === 0) {
await ctx.reply('No clans have been created yet. Use `/clan create` to start one!');
return;
}
// Sort by level (desc), then bank (desc)
clanList.sort((a, b) => {
if (b.level !== a.level) return b.level - a.level;
return b.bank - a.bank;
});
const top10 = clanList.slice(0, 10);
const leaderboard = top10
.map((clan, i) => {
const medal = i === 0 ? '🥇' : i === 1 ? '🥈' : i === 2 ? '🥉' : `${i + 1}.`;
return `${medal} **${clan.name}** — Level ${clan.level} • ${clan.bank} coins • ${clan.members.length} members`;
})
.join('\n');
await ctx.reply({
embed: {
title: '🏆 Clan Leaderboard',
description: leaderboard,
footer: { text: `${clanList.length} total clans` },
color: '#e67e22',
},
});
}
);
mee6.command(
'clan info',
{
description: 'View your clan information',
},
async (ctx) => {
const myClan = await getMemberClan(ctx.author.id);
if (!myClan) {
await ctx.reply('You are not in a clan. Create one with `/clan create` or ask for an invite!');
return;
}
const nextUpgrade = getUpgradeCost(myClan.clan.level);
const memberList = myClan.clan.members.map((id) => `<@${id}>`).join(', ');
await ctx.reply({
embed: {
title: `🏰 ${myClan.clan.name}`,
fields: [
{ name: 'Owner', value: `<@${myClan.clan.owner}>`, inline: true },
{ name: 'Level', value: `${myClan.clan.level}`, inline: true },
{ name: 'Bank', value: `${myClan.clan.bank} coins`, inline: true },
{ name: 'Members', value: memberList },
{
name: 'Next Upgrade',
value: `${nextUpgrade} coins (${Math.max(0, nextUpgrade - myClan.clan.bank)} needed)`,
},
],
color: '#3498db',
},
});
}
);