Add /lucky coinflip and /lucky dice against the bot for MEE6 coins, /lucky start (admins) which doubles their payouts for an hour and announces it in a channel I choose, /lucky stop, and a lucky hour that starts by itself every Saturday at 8pm UTC
Lucky Gambling lets members bet MEE6 coins on coin flips and dice rolls.
/lucky coinflip - Bet on heads or tails (2x payout on win)/lucky dice - Bet on a number 1-6 (5x payout on win)/lucky start - Admins can start lucky hour (doubles all payouts)/lucky stop - Admins can end lucky hour earlyEvery Saturday at 8pm UTC, lucky hour automatically starts for 1 hour. During lucky hour, all gambling payouts are doubled (coinflip pays 4x, dice pays 10x).
Admins can also manually start or stop lucky hour at any time. Configure the announcement channel and admin role in settings.
Made by MEE6. Remix it to get a copy of your own and change anything you like.
The coin landed on tails.
๐ธ You lost 100 coins.
heads
tails
-100 coins
The dice rolled a 2.
๐ธ You lost 50 coins.
4
2
-50 coins
โ Lucky hour started!
The coin landed on tails!
๐ You won 400 coins! ๐ (Lucky Hour bonus!)
tails
tails
+300 coins
The dice rolled a 1!
๐ You won 500 coins! ๐ (Lucky Hour bonus!)
1
1
+450 coins
// Lucky Gambling - Coin flip and dice games with lucky hour bonuses
mee6.settings({
announcement_channel: {
type: 'channel',
label: 'Lucky hour announcement channel',
required: true,
sample: 'announcements',
},
admin_role: {
type: 'role',
label: 'Admin role (can start/stop lucky hour)',
sample: 'Admin',
},
});
// A call moves at most 1,000,000,000 coins, the Economy plugin's own balance
// cap, and a lucky-hour dice win pays ten times the bet: bets stop at
// 100,000,000.
const MAX_BET = 100_000_000;
// Check if lucky hour is active
async function isLuckyHour(): Promise<boolean> {
const active = await mee6.store.get<boolean>('lucky_hour_active');
return active === true;
}
// Start lucky hour
async function startLuckyHour(ctx: any, channelId: string) {
await mee6.store.set('lucky_hour_active', true, { ttl: 3600 });
await mee6.schedule.once('lucky_hour_end', 3600, { channelId });
await ctx.send(channelId, {
embed: {
title: '๐ LUCKY HOUR STARTED!',
description:
'**All gambling payouts are DOUBLED for the next hour!**\n\nTry your luck with `/lucky coinflip` and `/lucky dice`!',
color: '#FFD700',
},
});
}
// Stop lucky hour
async function stopLuckyHour(ctx: any, channelId: string) {
await mee6.store.delete('lucky_hour_active');
await mee6.schedule.cancel('lucky_hour_end');
await ctx.send(channelId, {
embed: {
title: '๐ Lucky Hour Ended',
description: 'Payouts have returned to normal. Thanks for playing!',
color: '#999999',
},
});
}
// /lucky coinflip - Bet on heads or tails
mee6.command(
'lucky coinflip',
{
description: 'Flip a coin and bet MEE6 coins',
options: [
{
name: 'bet',
type: 'integer',
description: 'Amount of coins to bet (1 to 100000000)',
required: true,
},
{
name: 'choice',
type: 'string',
description: 'Choose heads or tails',
required: true,
choices: [
{ name: 'Heads', value: 'heads' },
{ name: 'Tails', value: 'tails' },
],
},
],
},
async (ctx) => {
const bet = ctx.option<number>('bet');
const choice = ctx.option<string>('choice');
// Validate bet amount
if (bet < 1 || bet > MAX_BET) {
await ctx.reply(`You can bet from 1 to ${MAX_BET.toLocaleString('en-US')} coins!`);
return;
}
// Check balance
const balance = await mee6.economy.balance(ctx.author.id);
if (balance.coins < bet) {
await ctx.reply(`You don't have enough coins! Your balance: ${balance.coins} coins.`);
return;
}
// Flip the coin
const result = Math.random() < 0.5 ? 'heads' : 'tails';
const won = result === choice;
// Calculate winnings
const lucky = await isLuckyHour();
const multiplier = lucky ? 2 : 1;
if (won) {
// The bet stays with the member: only the profit is paid, raised by
// the server's Economy game boosts on top of the Lucky Hour
const { amount: profit } = await mee6.economy.add(ctx.author.id, bet * (2 * multiplier - 1), {
boost: 'games',
});
const winnings = bet + profit;
await ctx.reply({
embed: {
title: '๐ช Coin Flip',
description: `The coin landed on **${result}**!\n\n๐ **You won ${winnings} coins!**${
lucky ? ' ๐ (Lucky Hour bonus!)' : ''
}`,
color: '#00FF00',
fields: [
{ name: 'Your choice', value: choice, inline: true },
{ name: 'Result', value: result, inline: true },
{ name: 'Profit', value: `+${profit} coins`, inline: true },
],
},
});
} else {
const { amount: lost } = await mee6.economy.remove(ctx.author.id, bet, { boost: 'games' });
await ctx.reply({
embed: {
title: '๐ช Coin Flip',
description: `The coin landed on **${result}**.\n\n๐ธ You lost ${lost} coins.`,
color: '#FF0000',
fields: [
{ name: 'Your choice', value: choice, inline: true },
{ name: 'Result', value: result, inline: true },
{ name: 'Loss', value: `-${lost} coins`, inline: true },
],
},
});
}
}
);
// /lucky dice - Bet on a dice roll (1-6)
mee6.command(
'lucky dice',
{
description: 'Roll a dice and bet MEE6 coins',
options: [
{
name: 'bet',
type: 'integer',
description: 'Amount of coins to bet (1 to 100000000)',
required: true,
},
{
name: 'number',
type: 'integer',
description: 'Pick a number (1-6)',
required: true,
},
],
},
async (ctx) => {
const bet = ctx.option<number>('bet');
const choice = ctx.option<number>('number');
// Validate inputs
if (bet < 1 || bet > MAX_BET) {
await ctx.reply(`You can bet from 1 to ${MAX_BET.toLocaleString('en-US')} coins!`);
return;
}
if (choice < 1 || choice > 6) {
await ctx.reply('You must pick a number between 1 and 6!');
return;
}
// Check balance
const balance = await mee6.economy.balance(ctx.author.id);
if (balance.coins < bet) {
await ctx.reply(`You don't have enough coins! Your balance: ${balance.coins} coins.`);
return;
}
// Roll the dice
const result = Math.floor(Math.random() * 6) + 1;
const won = result === choice;
// Calculate winnings (5x payout for guessing right, since 1/6 chance)
const lucky = await isLuckyHour();
const multiplier = lucky ? 2 : 1;
if (won) {
// The bet stays with the member: only the profit is paid, raised by
// the server's Economy game boosts on top of the Lucky Hour
const { amount: profit } = await mee6.economy.add(ctx.author.id, bet * (5 * multiplier - 1), {
boost: 'games',
});
const winnings = bet + profit;
await ctx.reply({
embed: {
title: '๐ฒ Dice Roll',
description: `The dice rolled a **${result}**!\n\n๐ **You won ${winnings} coins!**${
lucky ? ' ๐ (Lucky Hour bonus!)' : ''
}`,
color: '#00FF00',
fields: [
{ name: 'Your guess', value: `${choice}`, inline: true },
{ name: 'Result', value: `${result}`, inline: true },
{ name: 'Profit', value: `+${profit} coins`, inline: true },
],
},
});
} else {
const { amount: lost } = await mee6.economy.remove(ctx.author.id, bet, { boost: 'games' });
await ctx.reply({
embed: {
title: '๐ฒ Dice Roll',
description: `The dice rolled a **${result}**.\n\n๐ธ You lost ${lost} coins.`,
color: '#FF0000',
fields: [
{ name: 'Your guess', value: `${choice}`, inline: true },
{ name: 'Result', value: `${result}`, inline: true },
{ name: 'Loss', value: `-${lost} coins`, inline: true },
],
},
});
}
}
);
// /lucky start - Admin command to start lucky hour
mee6.command(
'lucky start',
{
description: 'Start lucky hour (doubles all gambling payouts)',
},
async (ctx) => {
const adminRole = ctx.settings.admin_role;
if (adminRole && !ctx.author.roles.includes(adminRole)) {
await ctx.reply('You need the admin role to start lucky hour!');
return;
}
const channelId = ctx.settings.announcement_channel;
if (!channelId) {
await ctx.reply('No announcement channel is configured. Ask an admin to set one in the dashboard.');
return;
}
const alreadyActive = await isLuckyHour();
if (alreadyActive) {
await ctx.reply('Lucky hour is already active!');
return;
}
await startLuckyHour(ctx, channelId);
await ctx.reply('โ
Lucky hour started!');
}
);
// /lucky stop - Admin command to stop lucky hour
mee6.command(
'lucky stop',
{
description: 'Stop the current lucky hour',
},
async (ctx) => {
const adminRole = ctx.settings.admin_role;
if (adminRole && !ctx.author.roles.includes(adminRole)) {
await ctx.reply('You need the admin role to stop lucky hour!');
return;
}
const channelId = ctx.settings.announcement_channel;
if (!channelId) {
await ctx.reply('No announcement channel is configured. Ask an admin to set one in the dashboard.');
return;
}
const active = await isLuckyHour();
if (!active) {
await ctx.reply('Lucky hour is not currently active!');
return;
}
await stopLuckyHour(ctx, channelId);
await ctx.reply('โ
Lucky hour stopped.');
}
);
// Schedule automatic lucky hour every Saturday at 8pm UTC (20:00)
mee6.schedule.cron('saturday_lucky_hour', '0 20 * * 6');
// Handle scheduled events
mee6.on('scheduled', async (ctx) => {
if (ctx.scheduleKey === 'saturday_lucky_hour') {
const channelId = ctx.settings.announcement_channel;
if (channelId) {
await startLuckyHour(ctx, channelId);
}
} else if (ctx.scheduleKey === 'lucky_hour_end') {
const p = ctx.payload as { channelId: string } | null;
if (p?.channelId) {
await mee6.store.delete('lucky_hour_active');
await ctx.send(p.channelId, {
embed: {
title: '๐ Lucky Hour Ended',
description: 'Payouts have returned to normal. Thanks for playing!',
color: '#999999',
},
});
}
}
});