Build a text adventure: /adventure starts a short story with two or three choices as buttons, each choice leads to the next scene from a tree in the code, some paths end in treasure and some in death, and /adventure stats shows how many endings a member has found
Text Adventure is an interactive story game where your choices matter!
How to play:
/adventure start โ Begin your journey through a mysterious forest/adventure stats โ View how many endings you've discoveredThe story has 5 unique endings to find โ 2 lead to treasure and 3 lead to different fates. Each choice branches the story in a new direction. Can you discover them all?
Made by MEE6. Remix it to get a copy of your own and change anything you like.
๐ณ๏ธ You slip behind the waterfall into the cave. The whispers become a gentle song, and you see them โ glowing crystals embedded in the walls!
You carefully collect several. They're worth a fortune! You've found the legendary Crystal Cave!
โจ You found treasure! โจ
๐ Ending discovered! (2/5 found)
You's journey through the forest
2 / 5
2
0
๐ You step onto the bridge. The ropes creak ominously with each step. Halfway across, a plank snaps!
You lose your balance and plunge into the raging river below. The current sweeps you away into darkness.
๐ The End ๐
๐ Ending discovered! (1/5 found)
// Text Adventure โ a branching story game with choices and collectible endings
interface Scene {
text: string;
choices: { label: string; next: string }[];
ending?: 'treasure' | 'death'; // marks terminal scenes
endingName?: string; // unique identifier for tracking
}
// The story tree โ each scene has choices leading to other scenes
const SCENES: Record<string, Scene> = {
start: {
text: '๐ฒ You stand at the edge of a dark forest. A worn path splits in two directions, and you hear distant sounds from both.\n\nTo the left, the soft glow of firelight flickers between the trees.\nTo the right, you hear the rush of water and strange whispers.',
choices: [
{ label: '๐ฅ Follow the firelight', next: 'firelight' },
{ label: '๐ง Head toward the water', next: 'river' },
],
},
firelight: {
text: '๐ฅ You approach a small clearing where a campfire crackles. An old traveler sits beside it, warming their hands.\n\n"Lost, are you?" they ask with a knowing smile. "I can offer you a map... or a warning."',
choices: [
{ label: '๐บ๏ธ Ask for the map', next: 'map' },
{ label: 'โ ๏ธ Ask for the warning', next: 'warning' },
{ label: '๐ Keep walking past', next: 'past_fire' },
],
},
river: {
text: "๐ง You reach a rushing river. The whispers grow louder โ they're coming from a cave behind the waterfall!\n\nA rickety rope bridge spans the river, leading deeper into the forest. The cave entrance beckons mysteriously.",
choices: [
{ label: '๐ Cross the bridge', next: 'bridge' },
{ label: '๐ณ๏ธ Enter the cave', next: 'cave' },
],
},
map: {
text: '๐บ๏ธ The traveler hands you an ancient map. It shows a hidden temple nearby, marked with an X.\n\nYou follow the map through the forest and discover a stone temple covered in vines. Inside, golden artifacts gleam in the darkness!',
choices: [],
ending: 'treasure',
endingName: 'temple_treasure',
},
warning: {
text: 'โ ๏ธ "Beware the bridge," the traveler whispers. "Many have crossed it. Few have returned."\n\nYou thank them and continue. Hours later, you emerge from the forest safely, wiser but empty-handed.',
choices: [],
ending: 'death',
endingName: 'safe_exit',
},
past_fire: {
text: '๐ You nod politely and walk past the campfire. The traveler watches you go with an amused expression.\n\nThe path leads to a dead end at a cliff edge. As you turn back, the ground crumbles beneath you!',
choices: [],
ending: 'death',
endingName: 'cliff_fall',
},
bridge: {
text: '๐ You step onto the bridge. The ropes creak ominously with each step. Halfway across, a plank snaps!\n\nYou lose your balance and plunge into the raging river below. The current sweeps you away into darkness.',
choices: [],
ending: 'death',
endingName: 'bridge_fall',
},
cave: {
text: "๐ณ๏ธ You slip behind the waterfall into the cave. The whispers become a gentle song, and you see them โ glowing crystals embedded in the walls!\n\nYou carefully collect several. They're worth a fortune! You've found the legendary Crystal Cave!",
choices: [],
ending: 'treasure',
endingName: 'crystal_cave',
},
};
// Render a scene with its choices as buttons
function renderScene(sceneId: string) {
const scene = SCENES[sceneId];
let content = scene.text;
// Add ending message
if (scene.ending === 'treasure') {
content += '\n\nโจ **You found treasure!** โจ';
} else if (scene.ending === 'death') {
content += '\n\n๐ **The End** ๐';
}
// Build buttons for non-ending scenes
const buttons = scene.choices.map((choice) => ({
label: choice.label,
customId: `adv_${choice.next}`,
style: 'primary' as const,
}));
// Add restart button on endings
if (scene.ending) {
buttons.push({
label: '๐ Start Over',
customId: 'adv_start',
style: 'secondary' as const,
});
}
return { content, buttons: buttons.length > 0 ? [buttons] : undefined };
}
// Track which endings a member has discovered
async function recordEnding(userId: string, endingName: string) {
const m = mee6.store.member(userId);
const found = await m.get<string[]>('endings_found', []);
if (!found.includes(endingName)) {
found.push(endingName);
await m.set('endings_found', found);
}
return found.length;
}
mee6.command('adventure start', { description: 'Begin a text adventure' }, async (ctx) => {
const scene = renderScene('start');
await ctx.reply(scene);
});
mee6.command('adventure stats', { description: 'View your adventure progress' }, async (ctx) => {
const m = mee6.store.member(ctx.author.id);
const found = await m.get<string[]>('endings_found', []);
const totalEndings = Object.values(SCENES).filter((s) => s.ending).length;
const treasures = Object.values(SCENES).filter(
(s) => s.ending === 'treasure' && found.includes(s.endingName!)
).length;
const deaths = Object.values(SCENES).filter((s) => s.ending === 'death' && found.includes(s.endingName!)).length;
await ctx.reply({
embed: {
title: '๐ Adventure Statistics',
description: `${ctx.author.displayName}'s journey through the forest`,
color: 0x2ecc71,
fields: [
{ name: '๐ฏ Endings Found', value: `${found.length} / ${totalEndings}`, inline: true },
{ name: 'โจ Treasures', value: `${treasures}`, inline: true },
{ name: '๐ Deaths', value: `${deaths}`, inline: true },
],
footer: { text: 'Try /adventure to discover more endings!' },
},
});
});
mee6.on('button', async (ctx) => {
if (!ctx.customId.startsWith('adv_')) return;
const sceneId = ctx.customId.replace('adv_', '');
const scene = SCENES[sceneId];
if (!scene) {
await ctx.reply({ content: 'Something went wrong!', ephemeral: true });
return;
}
// Record ending if this is a terminal scene
if (scene.ending && scene.endingName) {
const totalFound = await recordEnding(ctx.author.id, scene.endingName);
const allEndings = Object.values(SCENES).filter((s) => s.ending).length;
let endingMsg = '';
if (totalFound === allEndings) {
endingMsg = `\n\n๐ **Congratulations!** You've found all ${allEndings} endings!`;
} else {
endingMsg = `\n\n๐ Ending discovered! (${totalFound}/${allEndings} found)`;
}
const rendered = renderScene(sceneId);
await ctx.editOriginal({
content: rendered.content + endingMsg,
buttons: rendered.buttons,
});
} else {
// Continue the story
const rendered = renderScene(sceneId);
await ctx.editOriginal(rendered);
}
});