Build a collection game: /roll shows a random character from a list in settings as an embed with its picture and a rarity colour, a Claim button gives it to the first member who clicks within a minute, and /collection shows what someone owns Make the character catalogue editable as list settings (name, optional custom image URL, rarity), with eight existing characters and Battle for Wesnoth portrait URLs as defaults. Keep the portrait and its attribution visible after claiming.
Roll and collect characters
Made by MEE6. Remix it to get a copy of your own and change anything you like.

š You claimed Ash the Scout!
1 total characters ⢠1 unique
Ash the Scout
1 total characters ⢠1 unique
Frost the Ice Mage
// Character Collection Game
// /roll shows a random character with a Claim button
// /collection shows what you own
interface Character {
name: string;
image: string;
rarity: 'common' | 'rare' | 'epic' | 'legendary';
}
const RARITIES = {
common: { color: '#95a5a6', weight: 50 },
rare: { color: '#3498db', weight: 30 },
epic: { color: '#9b59b6', weight: 15 },
legendary: { color: '#f1c40f', weight: 5 },
};
// Character pool - customize this list
const CHARACTERS: Character[] = [
{
name: 'Luna the Moonkeeper',
image:
'https://raw.githubusercontent.com/wesnoth/wesnoth/99b5631d9fb3b8518d9fdee191d168f1e440019a/data/core/images/portraits/elves/sorceress.webp',
rarity: 'legendary',
},
{
name: 'Blaze the Fire Warrior',
image:
'https://raw.githubusercontent.com/wesnoth/wesnoth/99b5631d9fb3b8518d9fdee191d168f1e440019a/data/core/images/portraits/humans/mage-red.webp',
rarity: 'epic',
},
{
name: 'Sage the Wise',
image:
'https://raw.githubusercontent.com/wesnoth/wesnoth/99b5631d9fb3b8518d9fdee191d168f1e440019a/data/core/images/portraits/humans/mage-arch.webp',
rarity: 'epic',
},
{
name: 'Frost the Ice Mage',
image:
'https://raw.githubusercontent.com/wesnoth/wesnoth/99b5631d9fb3b8518d9fdee191d168f1e440019a/data/core/images/portraits/humans/mage-silver.webp',
rarity: 'rare',
},
{
name: 'Storm the Thunder Knight',
image:
'https://raw.githubusercontent.com/wesnoth/wesnoth/99b5631d9fb3b8518d9fdee191d168f1e440019a/data/core/images/portraits/humans/knight.webp',
rarity: 'rare',
},
{
name: 'Willow the Healer',
image:
'https://raw.githubusercontent.com/wesnoth/wesnoth/99b5631d9fb3b8518d9fdee191d168f1e440019a/data/core/images/portraits/elves/shaman.webp',
rarity: 'common',
},
{
name: 'Ash the Scout',
image:
'https://raw.githubusercontent.com/wesnoth/wesnoth/99b5631d9fb3b8518d9fdee191d168f1e440019a/data/core/images/portraits/elves/scout.webp',
rarity: 'common',
},
{
name: 'River the Ranger',
image:
'https://raw.githubusercontent.com/wesnoth/wesnoth/99b5631d9fb3b8518d9fdee191d168f1e440019a/data/core/images/portraits/elves/ranger%2Bfemale.webp',
rarity: 'common',
},
];
// Portraits from The Battle for Wesnoth. See ASSETS.md for sources and license.
function portraitCredit(image: string | null): string {
return image && CHARACTERS.some((character) => character.image === image)
? '\n\n[Art: The Battle for Wesnoth](https://github.com/wesnoth/wesnoth) Ā· [License](https://wiki.wesnoth.org/Wesnoth:Copyrights)'
: '';
}
mee6.settings({
roll_channel: {
type: 'channel',
label: 'Roll channel (leave empty to allow all channels)',
sample: 'character-rolls',
},
characters: {
type: 'list',
label: 'Characters',
maxItems: 25,
fields: {
name: { type: 'string', label: 'Name', required: true },
image: {
type: 'string',
label: 'Image URL',
description: 'Replace with your own image URL, or leave empty for no image.',
},
rarity: {
type: 'string',
label: 'Rarity',
required: true,
choices: ['common', 'rare', 'epic', 'legendary'],
default: 'common',
},
},
default: CHARACTERS,
},
});
function weightedRandom(CHARACTERS: Character[]): Character {
const weights = CHARACTERS.map((c) => RARITIES[c.rarity].weight);
const total = weights.reduce((sum, w) => sum + w, 0);
let random = Math.random() * total;
for (let i = 0; i < CHARACTERS.length; i++) {
random -= weights[i];
if (random <= 0) return CHARACTERS[i];
}
return CHARACTERS[CHARACTERS.length - 1];
}
mee6.command('roll', { description: 'Roll a random character' }, async (ctx) => {
const allowedChannel = ctx.settings.roll_channel;
if (allowedChannel && ctx.channelId !== allowedChannel) {
await ctx.reply({
content: `ā ļø Please use <#${allowedChannel}> for rolling characters.`,
ephemeral: true,
});
return;
}
const characters = ctx.settings.characters as Character[];
if (!characters.length) {
await ctx.reply('No characters configured. Add characters in settings.');
return;
}
const character = weightedRandom(characters);
const rarityInfo = RARITIES[character.rarity];
const image = character.image?.trim() || null;
const sent = await ctx.reply({
embed: {
title: character.name,
description: `**${character.rarity.toUpperCase()}**\n\nClick Claim to add this character to your collection!${portraitCredit(
image
)}`,
color: rarityInfo.color,
...(image ? { image_url: image } : {}),
footer: { text: 'You have 60 seconds to claim' },
},
buttons: [{ label: 'Claim', customId: 'claim', style: 'success' }],
});
if (image) await mee6.store.set(`claim_image_${sent.messageId}`, image, { ttl: 60 });
// Store the claimable character with a 60-second expiry
await mee6.store.set(`claim_${sent.messageId}`, character.name, { ttl: 60 });
await mee6.store.set(`claim_rarity_${sent.messageId}`, character.rarity, { ttl: 60 });
});
mee6.on('button', async (ctx) => {
if (ctx.customId === 'claim') {
const characterName = await mee6.store.get<string>(`claim_${ctx.message.id}`);
if (!characterName) {
await ctx.reply({ content: 'ā° This character is no longer available to claim.', ephemeral: true });
return;
}
// Atomic claim - only one person can claim it
const claimed = await mee6.store.compareAndSet(`claim_${ctx.message.id}`, characterName, ctx.author.id, {
ttl: 60,
});
if (!claimed) {
await ctx.reply({ content: 'šØ Someone else claimed it first!', ephemeral: true });
return;
}
const rarity = await mee6.store.get<string>(`claim_rarity_${ctx.message.id}`, 'common');
const image = await mee6.store.get<string>(`claim_image_${ctx.message.id}`);
// Add to member's collection
const m = mee6.store.member(ctx.author.id);
const collection = await m.get<Record<string, number>>('collection', {});
collection[characterName] = (collection[characterName] || 0) + 1;
await m.set('collection', collection);
// Update the message to show it's claimed
await ctx.editOriginal({
embed: {
title: characterName,
...(image ? { image_url: image } : {}),
description: `**${rarity.toUpperCase()}**\n\nā
Claimed by ${ctx.author.displayName}!${portraitCredit(image)}`,
color: RARITIES[rarity as keyof typeof RARITIES].color,
footer: { text: `Claimed by ${ctx.author.username}` },
},
buttons: [{ label: 'Claimed', customId: 'claimed', style: 'secondary' }],
});
await ctx.reply({ content: `š You claimed **${characterName}**!`, ephemeral: true });
}
});
mee6.command(
'collection',
{
description: 'View your character collection',
options: [{ name: 'user', type: 'user', description: "View someone else's collection" }],
ephemeral: true,
},
async (ctx) => {
const targetId = ctx.option<string>('user', ctx.author.id);
const target = await mee6.getMember(targetId);
if (!target) {
await ctx.reply('ā User not found.');
return;
}
const m = mee6.store.member(targetId);
const collection = await m.get<Record<string, number>>('collection', {});
const entries = Object.entries(collection);
if (entries.length === 0) {
const pronoun = targetId === ctx.author.id ? "You don't" : "They don't";
await ctx.reply(`${pronoun} have any characters yet. Use \`/roll\` to collect some!`);
return;
}
// Group by rarity
const byRarity: Record<string, string[]> = {
legendary: [],
epic: [],
rare: [],
common: [],
};
for (const [name, count] of entries) {
const char =
(ctx.settings.characters as Character[]).find((c) => c.name === name) ||
CHARACTERS.find((c) => c.name === name);
if (char) {
const display = count > 1 ? `${name} (Ć${count})` : name;
byRarity[char.rarity].push(display);
} else {
byRarity.common.push(`${name} (Ć${count}, retired)`);
}
}
const fields = [];
const rarityOrder: Array<keyof typeof RARITIES> = ['legendary', 'epic', 'rare', 'common'];
for (const rarity of rarityOrder) {
if (byRarity[rarity].length > 0) {
fields.push({
name: `${rarity.toUpperCase()} (${byRarity[rarity].length})`,
value: byRarity[rarity].join('\n'),
inline: false,
});
}
}
const total = entries.reduce((sum, [_, count]) => sum + count, 0);
const unique = entries.length;
await ctx.reply({
embed: {
title: `${target.displayName}'s Collection`,
description: `**${total}** total characters ⢠**${unique}** unique`,
fields,
color: '#3498db',
thumbnail_url: target.avatarUrl,
},
});
}
);