Add /colors which posts a message with one button per colour role I choose in settings (five roles); clicking a button gives that role and removes the other four Use list settings for up to five colour roles selected by the admin. Prefix each button label with the closest coloured circle emoji based on the actual role colour, using a white circle for roles without a colour.
Members choose their colour role from a button panel. /colors posts buttons for up to five roles configured in settings. Clicking a button assigns that role and removes the other four; clicking again removes it. Perfect for cosmetic colour roles without needing permission management.
Made by MEE6. Remix it to get a copy of your own and change anything you like.
🎨 Choose your colour:
// Colour role picker — /colors posts buttons that assign one of five roles exclusively
mee6.settings({
colors: {
type: 'list',
label: 'Colour roles',
maxItems: 5,
fields: { role: { type: 'role', label: 'Role', required: true } },
default: [{}, {}, {}, {}, {}],
sample: ['Red', 'Blue', 'Green', 'Yellow', 'Purple'].map((role) => ({ role })),
},
});
// Unicode circles approximate the actual role colour; Discord buttons have fixed styles.
function colourEmoji(color: number): string {
if (!color) return '⚪';
const palette: [number, string][] = [
[0xe74c3c, '🔴'],
[0x3498db, '🔵'],
[0x2ecc71, '🟢'],
[0xf1c40f, '🟡'],
[0x9b59b6, '🟣'],
[0xe67e22, '🟠'],
[0x8b4513, '🟤'],
[0xffffff, '⚪'],
[0x000000, 'âš«'],
];
const distance = (candidate: number) =>
[16, 8, 0].reduce((sum, shift) => sum + (((color >> shift) & 255) - ((candidate >> shift) & 255)) ** 2, 0);
return palette.reduce((nearest, candidate) =>
distance(candidate[0]) < distance(nearest[0]) ? candidate : nearest
)[1];
}
mee6.command('colors', { description: 'Pick your colour role' }, async (ctx) => {
const roles = await mee6.listRoles();
const colors = (ctx.settings.colors as { role: string }[]).map((row) => row.role).filter(Boolean); // only the ones that are set
if (colors.length === 0) {
await ctx.reply('No colour roles configured yet — an admin can set them in the dashboard.');
return;
}
// Build buttons from the role names
const buttons = colors.map((id) => {
const role = roles.find((r) => r.id === id);
return {
label: `${colourEmoji(role?.color ?? 0)} ${role?.name ?? 'Unknown role'}`,
customId: `color_${id}`,
style: 'primary' as const,
};
});
await ctx.reply({
content: '🎨 Choose your colour:',
buttons,
});
});
mee6.on('button', async (ctx) => {
if (!ctx.customId.startsWith('color_')) return;
const roleId = ctx.customId.replace('color_', '');
const colors = (ctx.settings.colors as { role: string }[]).map((row) => row.role).filter(Boolean);
if (!colors.includes(roleId)) {
await ctx.reply({ content: 'This colour is no longer available. Run /colors again.', ephemeral: true });
return;
}
// Remove all other colour roles
const toRemove = colors.filter((id) => id !== roleId && ctx.author.roles.includes(id));
for (const id of toRemove) {
await mee6.removeRole(ctx.author.id, id);
}
// Toggle the clicked role
if (ctx.author.roles.includes(roleId)) {
await mee6.removeRole(ctx.author.id, roleId);
await ctx.reply({ content: '🎨 Colour role removed.', ephemeral: true });
} else {
await mee6.addRole(ctx.author.id, roleId);
const roles = await mee6.listRoles();
const role = roles.find((r) => r.id === roleId);
await ctx.reply({ content: `🎨 You now have the **${role?.name}** role!`, ephemeral: true });
}
});