Give three roles I choose in settings when a member's MEE6 coins pass 1,000, 10,000 and 100,000, checked whenever they send a message, take a role back if they drop below its threshold, and add /wealth which shows a member's tier Use an editable list of named coin thresholds and roles, with Bronze/Silver/Gold thresholds as defaults and roles chosen by the admin.
Wealth Roles automatically grants and removes roles based on members' MEE6 coin balances.
/wealth shows any member's current tier and progressSet three roles in the dashboard for each wealth tier (Bronze, Silver, Gold). Members accumulate all roles they qualify for โ someone with 50,000 coins has both Bronze and Silver.
Made by MEE6. Remix it to get a copy of your own and change anything you like.
520 coins
None
480 coins until Bronze
๐ Daily reward claimed: +58 coins. You now have 578.
๐ผ You worked and earned 38 coins. You now have 616.
๐ผ You worked and earned 79 coins. You now have 695.
๐ผ You worked and earned 66 coins. You now have 761.
๐ผ You worked and earned 63 coins. You now have 824.
๐ผ You worked and earned 50 coins. You now have 874.
๐ผ You worked and earned 58 coins. You now have 932.
๐ผ You worked and earned 52 coins. You now have 984.
๐ผ You worked and earned 57 coins. You now have 1041.
1,041 coins
Bronze
8,959 coins until Silver
410 coins
None
590 coins until Bronze
// Wealth Roles โ grant roles based on MEE6 coin thresholds
interface Tier {
name: string;
threshold: number;
role: string;
}
mee6.settings({
tiers: {
type: 'list',
label: 'Wealth tiers',
maxItems: 5,
fields: {
name: { type: 'string', label: 'Tier name', required: true },
threshold: { type: 'integer', label: 'Coins required', required: true, default: 1000 },
role: { type: 'role', label: 'Role', required: true },
},
default: [
{ name: 'Bronze', threshold: 1000 },
{ name: 'Silver', threshold: 10000 },
{ name: 'Gold', threshold: 100000 },
],
sample: [
{ name: 'Bronze', threshold: 1000, role: 'Bronze' },
{ name: 'Silver', threshold: 10000, role: 'Silver' },
{ name: 'Gold', threshold: 100000, role: 'Gold' },
],
},
});
function tiers(settings: any): Tier[] {
return (settings.tiers as Tier[])
.filter((tier) => tier.role && tier.threshold >= 0)
.sort((a, b) => a.threshold - b.threshold);
}
/** Check and update a member's wealth roles based on their coin balance. */
async function updateWealthRoles(userId: string, settings: any) {
const balance = await mee6.economy.balance(userId);
const member = await mee6.getMember(userId);
if (!member) return;
for (const tier of tiers(settings)) {
const roleId = tier.role;
if (!roleId) continue; // Skip unconfigured roles
const hasRole = member.roles.includes(roleId);
const shouldHave = balance.coins >= tier.threshold;
if (shouldHave && !hasRole) {
await mee6.addRole(userId, roleId);
mee6.log(`Granted ${tier.name} to ${userId} (${balance.coins} coins)`);
} else if (!shouldHave && hasRole) {
await mee6.removeRole(userId, roleId);
mee6.log(`Removed ${tier.name} from ${userId} (${balance.coins} coins)`);
}
}
}
// A balance does not move on every message: one check per member every
// five minutes keeps a busy channel from spending its calls on role checks.
mee6.on('message', async (ctx) => {
const m = mee6.store.member(ctx.author.id);
const checkedAt = await m.get<number>('wealth_checked_at', 0);
if (Date.now() - checkedAt < 5 * 60 * 1000) return;
await m.set('wealth_checked_at', Date.now());
await updateWealthRoles(ctx.author.id, ctx.settings);
});
mee6.command(
'wealth',
{
description: "Check your or another member's wealth tier",
options: [{ name: 'member', type: 'user', description: 'Member to check' }],
},
async (ctx) => {
const targetId = ctx.option<string>('member', ctx.author.id);
const balance = await mee6.economy.balance(targetId);
const member = await mee6.getMember(targetId);
if (!member) {
await ctx.reply('Member not found.');
return;
}
const TIERS = tiers(ctx.settings);
if (!TIERS.length) {
await ctx.reply('No wealth tiers configured.');
return;
}
// Determine their tier
let tierName = 'None';
let nextTier = TIERS[0];
let progress = '';
for (let i = TIERS.length - 1; i >= 0; i--) {
if (balance.coins >= TIERS[i].threshold) {
tierName = TIERS[i].name;
nextTier = i < TIERS.length - 1 ? TIERS[i + 1] : null;
break;
} else {
nextTier = TIERS[i];
}
}
if (nextTier) {
const remaining = nextTier.threshold - balance.coins;
progress = `\n${remaining.toLocaleString()} coins until **${nextTier.name}**`;
} else {
progress = '\nโจ Maximum tier reached!';
}
await ctx.reply({
embed: {
title: `๐ฐ ${member.displayName}'s Wealth`,
description: `**${balance.coins.toLocaleString()}** coins`,
fields: [
{ name: 'Current Tier', value: tierName, inline: true },
{ name: 'Progress', value: progress.trim() || 'Maximum tier reached!' },
],
color: '#f1c40f',
},
});
}
);