Build a Memory game on a 4x4 grid: eight pairs of cards, each pair showing one of eight different animals you make with the image model, plus a card back. The board is one picture drawn with mee6.board and sixteen numbered buttons under it flip a card; two flipped cards that match stay face up, two that do not turn back at the next click; the message is edited in place, and when every pair is found the game says how many tries it took
Play a classic memory matching game with 16 cards on a 4×4 grid. Find all 8 pairs of cute animals by flipping two cards at a time. Matches stay face-up, non-matches flip back. Play solo or challenge a friend — the game tracks your tries and announces when you've found them all!
Made by MEE6. Remix it to get a copy of your own and change anything you like.
🎉 Game complete! Found all pairs in 10 tries!

// Memory Game: 4x4 grid with eight pairs of animal cards
interface GameState {
board: string[]; // 16 cells with animal names
flipped: number[]; // indices of face-up cards
matched: number[]; // indices of matched pairs
tries: number;
player1: string;
player2: string | null;
currentPlayer: string;
}
const ANIMALS = ['cat', 'dog', 'fox', 'bear', 'rabbit', 'panda', 'owl', 'lion'];
// Create a shuffled board with 8 pairs
function createBoard(): string[] {
const pairs = [...ANIMALS, ...ANIMALS]; // 16 cards total
// Shuffle using Fisher-Yates
for (let i = pairs.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[pairs[i], pairs[j]] = [pairs[j], pairs[i]];
}
return pairs;
}
// Generate the board visual
async function drawBoard(game: GameState): Promise<string> {
const cells: string[][] = [];
for (let row = 0; row < 4; row++) {
const rowCells: string[] = [];
for (let col = 0; col < 4; col++) {
const idx = row * 4 + col;
if (game.matched.includes(idx) || game.flipped.includes(idx)) {
// Show the animal
rowCells.push(game.board[idx]);
} else {
// Show card back
rowCells.push('card_back');
}
}
cells.push(rowCells);
}
return await mee6.board({
cells,
cell: 64,
light: '#F0F0F0',
dark: '#E0E0E0',
});
}
// Create button grid (16 buttons in 4 rows)
function createButtons(game: GameState): any[][] {
const buttons: any[][] = [];
for (let row = 0; row < 4; row++) {
const rowButtons: any[] = [];
for (let col = 0; col < 4; col++) {
const idx = row * 4 + col;
const disabled = game.matched.includes(idx) || game.flipped.includes(idx);
rowButtons.push({
label: `${idx + 1}`,
customId: `card_${idx}`,
style: disabled ? 'secondary' : 'primary',
disabled,
});
}
buttons.push(rowButtons);
}
return buttons;
}
// Status message
function statusMessage(game: GameState): string {
if (game.matched.length === 16) {
return `🎉 Game complete! Found all pairs in **${game.tries}** tries!`;
}
const p1 = `<@${game.player1}>`;
const p2 = game.player2 ? `<@${game.player2}>` : 'solo';
const current = `<@${game.currentPlayer}>`;
return `🎴 Memory Game | Players: ${p1}${game.player2 ? ` vs ${p2}` : ' (solo)'}\n${current}'s turn | Pairs found: ${
game.matched.length / 2
}/8 | Tries: ${game.tries}`;
}
mee6.command(
'memory',
{
description: 'Start a memory card game',
options: [
{
name: 'opponent',
type: 'user',
description: 'Play against someone (optional)',
required: false,
},
],
},
async (ctx) => {
const opponent = ctx.option<string>('opponent');
// Don't allow playing against yourself
if (opponent === ctx.author.id) {
await ctx.reply('You cannot play against yourself!');
return;
}
const game: GameState = {
board: createBoard(),
flipped: [],
matched: [],
tries: 0,
player1: ctx.author.id,
player2: opponent || null,
currentPlayer: ctx.author.id,
};
const boardUrl = await drawBoard(game);
const sent = await ctx.reply({
content: statusMessage(game),
embed: { image_url: boardUrl, color: 0x5865f2 },
buttons: createButtons(game),
});
await mee6.store.set(`memory_${sent.messageId}`, game, { ttl: 3600 });
}
);
mee6.on('button', async (ctx) => {
if (!ctx.customId?.startsWith('card_')) return;
const game = await mee6.store.get<GameState>(`memory_${ctx.message.id}`);
if (!game) return;
// Check if this player is in the game
if (ctx.author.id !== game.player1 && ctx.author.id !== game.player2) {
await ctx.reply({ content: 'This is not your game!', ephemeral: true });
return;
}
// Check if it's their turn
if (ctx.author.id !== game.currentPlayer) {
await ctx.reply({ content: 'It is not your turn!', ephemeral: true });
return;
}
const cardIdx = parseInt(ctx.customId.split('_')[1]);
// Can't flip already matched or flipped cards
if (game.matched.includes(cardIdx) || game.flipped.includes(cardIdx)) {
return;
}
// Flip the card
game.flipped.push(cardIdx);
// If this is the second card flipped
if (game.flipped.length === 2) {
game.tries++;
const [first, second] = game.flipped;
// Check if they match
if (game.board[first] === game.board[second]) {
// Match! Add to matched and clear flipped
game.matched.push(first, second);
game.flipped = [];
} else {
// No match - cards will flip back on next click, switch turns
if (game.player2) {
game.currentPlayer = game.currentPlayer === game.player1 ? game.player2 : game.player1;
}
}
} else if (game.flipped.length > 2) {
// More than 2 flipped means previous pair didn't match - flip them back
game.flipped = [cardIdx];
}
const boardUrl = await drawBoard(game);
await ctx.editOriginal({
content: statusMessage(game),
embed: { image_url: boardUrl, color: 0x5865f2 },
buttons: createButtons(game),
});
await mee6.store.set(`memory_${ctx.message.id}`, game, { ttl: 3600 });
});
The pictures this example ships with. Remix it to change them or add your own.
bearcard_backcatdogfoxlionowlpandarabbit