Add /slots which takes a bet in MEE6 coins and spins three reels of emojis I pick in settings, edits the message three times so the reels stop one after another, pays 3x for a pair and 10x for three of a kind, and lets the admin set the house edge between 0 and 20% in settings Use the emoji setting type for each Unicode emoji, with a list of emoji rows when there are several.
A slot machine game where members bet MEE6 coins and watch three reels spin with animated stops. Pays 3x for a pair and 10x for three of a kind. Admins can customize the reel symbols, house edge (0-20%), and min/max bet amounts in settings.
Made by MEE6. Remix it to get a copy of your own and change anything you like.
🎰 [ 🍋 | 🍋 | 🍇 ]
✨ PAIR! You won 142 coins! (3x) 💰 New balance: 322 coins
🎰 [ 🍒 | 🍒 | 🍒 ]
✨ THREE OF A KIND! You won 950 coins! (10x) 💰 New balance: 1360 coins
❌ You only have 95 coins. You need 200 to play.
❌ Minimum bet is 10 coins.
❌ Maximum bet is 1000 coins.
// Slot machine: three reels of configurable emojis, a house edge the admin sets
mee6.settings({
symbols: {
type: 'list',
label: 'Reel symbols',
required: true,
maxItems: 10,
fields: { emoji: { type: 'emoji', label: 'Emoji', required: true } },
default: ['🍒', '🍋', '🍊', '🍇', '💎', '⭐'].map((emoji) => ({ emoji })),
},
house_edge: {
type: 'integer',
label: 'House edge percentage (0-20)',
default: 5,
sample: 5,
},
min_bet: {
type: 'integer',
label: 'Minimum bet',
default: 10,
sample: 10,
},
max_bet: {
type: 'integer',
label: 'Maximum bet (up to 100,000,000)',
default: 1000,
sample: 1000,
},
});
// A call moves at most 1,000,000,000 coins, the Economy plugin's own balance
// cap, and three of a kind pays up to ten times the bet on top of it: bets
// stop at 100,000,000, whatever the settings say.
const MAX_BET = 100_000_000;
interface SpinResult {
symbols: string[];
payout: number;
multiplier: number;
}
/** Parse symbols from settings, clean and validate. */
function getSymbols(settings: any): string[] {
// Keep existing deployments with the former comma-separated setting readable.
const value = settings.symbols ?? '🍒,🍋,🍊,🍇,💎,⭐';
const raw =
typeof value === 'string'
? value.split(',').map((s) => s.trim())
: value.map((row: { emoji: string }) => row.emoji || '');
return raw.filter((s: string) => s.length > 0).slice(0, 10); // max 10 unique symbols
}
/** Pick a random symbol from the pool. */
function randomSymbol(symbols: string[]): string {
return symbols[Math.floor(Math.random() * symbols.length)];
}
/** Calculate payout: 3x for pair, 10x for three of a kind. */
function calculatePayout(reels: string[], bet: number, houseEdge: number): SpinResult {
const [a, b, c] = reels;
let multiplier = 0;
if (a === b && b === c) {
// Three of a kind
multiplier = 10;
} else if (a === b || b === c || a === c) {
// Pair
multiplier = 3;
}
// Apply house edge: reduce effective payout
const adjustedMultiplier = multiplier > 0 ? multiplier * (1 - houseEdge / 100) : 0;
const payout = Math.floor(bet * adjustedMultiplier);
return { symbols: reels, payout, multiplier };
}
/** Format the slot machine display. */
function formatSlots(reel1: string, reel2: string, reel3: string): string {
return `🎰 [ ${reel1} | ${reel2} | ${reel3} ]`;
}
mee6.command(
'slots',
{
description: 'Spin the slot machine',
options: [{ name: 'bet', type: 'integer', description: 'Amount to bet', required: true }],
},
async (ctx) => {
const bet = ctx.option<number>('bet');
const symbols = getSymbols(ctx.settings);
if (!symbols.length) {
await ctx.reply('Choose at least one reel emoji in settings before playing.');
return;
}
const maxBet = Math.min(ctx.settings.max_bet || 1000, MAX_BET);
const minBet = Math.min(Math.max(ctx.settings.min_bet || 10, 1), maxBet);
const houseEdge = Math.max(0, Math.min(20, ctx.settings.house_edge || 5));
// Validate bet
if (bet < minBet) {
await ctx.reply(`❌ Minimum bet is **${minBet}** coins.`);
return;
}
if (bet > maxBet) {
await ctx.reply(`❌ Maximum bet is **${maxBet}** coins.`);
return;
}
// Check balance
const balance = await mee6.economy.balance(ctx.author.id);
if (balance.coins < bet) {
await ctx.reply(`❌ You only have **${balance.coins}** coins. You need **${bet}** to play.`);
return;
}
// The bet is taken before the reels spin: spins started side by side
// cannot play with coins that are already staked
await mee6.economy.remove(ctx.author.id, bet);
// Generate final result
const finalReels = [randomSymbol(symbols), randomSymbol(symbols), randomSymbol(symbols)];
const result = calculatePayout(finalReels, bet, houseEdge);
// The reels stop one after another: the reply, then three edits of it.
// Editing costs no message budget, and a run cannot wait, so the edits
// follow each other as fast as Discord takes them.
const sent = await ctx.reply({
content: `${formatSlots('🎰', '🎰', '🎰')}\n**Spinning...**`,
});
const [r1, r2, r3] = finalReels;
await mee6.editMessage(sent.channelId, sent.messageId, {
content: `${formatSlots(r1, '🎰', '🎰')}\n**Spinning...**`,
});
await mee6.editMessage(sent.channelId, sent.messageId, {
content: `${formatSlots(r1, r2, '🎰')}\n**Spinning...**`,
});
let message = `${formatSlots(r1, r2, r3)}\n`;
if (result.payout > 0) {
// The stake comes back as is; the winnings take the server's Economy
// game boosts
await mee6.economy.add(ctx.author.id, bet);
const won = (await mee6.economy.add(ctx.author.id, result.payout, { boost: 'games' })).amount;
message += `\n✨ **${result.multiplier === 10 ? 'THREE OF A KIND' : 'PAIR'}!** You won **${won}** coins! (${
result.multiplier
}x)`;
} else {
// A "games losses" boost on the server takes its share more of the bet
const { gamesLosses } = await mee6.economy.boost();
const extra = Math.round((bet * gamesLosses) / 100);
if (extra > 0) {
await mee6.economy.remove(ctx.author.id, extra);
}
message += `\n❌ No match. You lost **${bet + extra}** coins.`;
}
const newBalance = await mee6.economy.balance(ctx.author.id);
message += `\n💰 New balance: **${newBalance.coins}** coins`;
await mee6.editMessage(sent.channelId, sent.messageId, { content: message });
}
);