const { Client, GatewayIntentBits, EmbedBuilder } = require('discord.js'); const express = require('express'); const { QuickDB } = require('quick.db'); const db = new QuickDB(); const app = express(); app.get('/', (req, res) => res.send('Midas is Online 24/7!')); app.listen(7860); const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMembers ] }); const userSchema = new mongoose.Schema({ userId: String, wallet: { type: Number, default: 0 }, shields: { type: Number, default: 0 }, items: { type: Array, default: [] } }); const User = mongoose.model('User', userSchema); const PREFIX = 'm.'; client.once('ready', () => { console.log(`āœ… Midas is online! Logged in as ${client.user.tag}`); }); client.on('messageCreate', async (message) => { if (!message.content.startsWith(PREFIX) || message.author.bot) return; const args = message.content.slice(PREFIX.length).trim().split(/ +/); const command = args.shift().toLowerCase(); // --- LEVELING SYSTEM --- let currentXP = await db.get(`xp_${message.author.id}`) || 0; let currentLvl = await db.get(`lvl_${message.author.id}`) || 0; // Give 10-20 XP per command let xpAdd = Math.floor(Math.random() * 11) + 10; let nextLvlXP = (currentLvl + 1) * 100; // Requirement: Level 1 = 100XP, Level 2 = 200XP... await db.add(`xp_${message.author.id}`, xpAdd); if (currentXP + xpAdd >= nextLvlXP) { let newLvl = currentLvl + 1; await db.set(`lvl_${message.author.id}`, newLvl); await db.set(`xp_${message.author.id}`, 0); // Reset XP for next level // Reward Formula: 500 + (Level - 1) * 150 // Lvl 1: 500 | Lvl 2: 650 | Lvl 3: 800 let reward = 500 + (newLvl - 1) * 150; await db.add(`wallet_${message.author.id}`, reward); message.reply(`✨ **LEVEL UP!** You are now **Level ${newLvl}**!\nšŸŽ You received a bonus of **$${reward.toLocaleString()}**.`); } if (command === 'rank' || command === 'level') { let target = message.mentions.users.first() || message.author; let xp = await db.get(`xp_${target.id}`) || 0; let lvl = await db.get(`lvl_${target.id}`) || 0; let needed = (lvl + 1) * 100; const rankEmbed = new EmbedBuilder() .setColor('#FFD700') .setTitle(`${target.username}'s Rank`) .addFields( { name: '⭐ Level', value: `${lvl}`, inline: true }, { name: 'šŸ“ˆ XP', value: `${xp} / ${needed}`, inline: true } ) .setFooter({ text: "Run more commands to level up!" }); return message.reply({ embeds: [rankEmbed] }); } // 1. !bal if (command === 'help' || command === 'h') { const helpEmbed = new EmbedBuilder() .setColor('#FFD700') .setTitle('šŸ”± Midas Official Help Menu') .setDescription('Welcome to the kingdom! Here are the commands you can use to build your empire.') .setThumbnail(client.user.displayAvatarURL()) .addFields( { name: 'šŸ’° Economy & Growth', value: '`bal`, `bank`, `dep`, `with`, `work`, `daily`, `prestige`, `profile`', inline: false }, { name: 'šŸŽ° Gambling (High Risk)', value: '`slots`, `coinflip`, `lotto`', inline: false }, { name: '🄷 Crime & Social', value: '`rob`, `give`, `rank`, `lb [global/level]`', inline: false }, { name: 'šŸŽ’ Items & Crates', value: '`shop`, `inv`, `use`, `fish`', inline: false } ) .setFooter({ text: 'Prefix: m. | Use m.help [command] for details' }) .setTimestamp(); // Optional: If they want info on a specific command if (args[0]) { let cmd = args[0].toLowerCase(); if (cmd === 'slots') return message.reply("šŸŽ° **Slots:** Bet money to match 3 symbols. Payout is 10x!"); if (cmd === 'rob') return message.reply("🄷 **Rob:** Try to steal from a user. Watch out for shields!"); if (cmd === 'lotto') return message.reply("šŸŽ« **Lotto:** Buy tickets for a 24h jackpot. More gold = higher chance."); } return message.reply({ embeds: [helpEmbed] }); } if (command === 'fish') { let inv = await db.get(`items_${message.author.id}`) || []; // Check for rods let hasEpic = inv.includes('Epic Fishing Rod'); let hasGood = inv.includes('Good Fishing Rod'); let hasOld = inv.includes('Old Fishing Rod'); if (!hasEpic && !hasGood && !hasOld) { return message.reply("šŸŽ£ You don't have a fishing rod! Buy an **Old Fishing Rod** in the shop first."); } // Cooldown logic (30s) let lastFish = await db.get(`fishCD_${message.author.id}`); if (lastFish !== null && 10000 - (Date.now() - lastFish) > 0) return message.reply("šŸŽ£ Calm down, the fish are scared! Wait a few seconds."); await db.set(`fishCD_${message.author.id}`, Date.now()); // Luck Multiplier let luck = 1; if (hasGood) luck = 1.5; if (hasEpic) luck = 3; const fishTypes = [ { id: 'boot', name: "Old Boot", chance: 40 / luck }, { id: 'fish', name: "Common Fish", chance: 30 }, { id: 'tropical', name: "Tropical Fish", chance: 15 * luck }, { id: 'puffer', name: "Pufferfish", chance: 10 * luck }, { id: 'shark', name: "Shark", chance: 4 * luck }, { id: 'whale', name: "Golden Whale", chance: 1 * luck } ]; // Randomized Logic let rng = Math.random() * 100; let caught = fishTypes[0]; let sum = 0; for (let f of fishTypes) { sum += f.chance; if (rng <= sum) { caught = f; break; } } // ADD TO INVENTORY await db.push(`items_${message.author.id}`, caught.name); return message.reply(`šŸŽ£ You used your **${hasEpic ? 'Epic' : hasGood ? 'Good' : 'Old'} Rod** and caught a **${caught.name}**! It's been added to your inventory.`); } if (command === 'sell') { let itemToSell = args.join(" ").toLowerCase(); if (!itemToSell) return message.reply("What do you want to sell? Example: `m.sell common fish`ćƒćƒ©ćƒ³ć‚¹"); let inv = await db.get(`items_${message.author.id}`) || []; // Define Prices const prices = { "old boot": 10, "common fish": 50, "tropical fish": 150, "pufferfish": 300, "shark": 1200, "golden whale": 5000 }; // Find the item in inventory (case insensitive) let itemIndex = inv.findIndex(i => i.toLowerCase() === itemToSell); if (itemIndex === -1) return message.reply("You don't have that item in your inventory!"); let sellPrice = prices[itemToSell]; if (!sellPrice) return message.reply("You can't sell that item to the shop."); // Remove from array and add money inv.splice(itemIndex, 1); await db.set(`items_${message.author.id}`, inv); await db.add(`wallet_${message.author.id}`, sellPrice); return message.reply(`šŸ’° You sold **${itemToSell}** for **$${sellPrice.toLocaleString()}**!`); } if (command === 'balance' || command === 'bal' || command === 'cash') { let balance = await db.get(`wallet_${message.author.id}`) || 0; return message.reply(`šŸ’° **Midas:** You currently have **$${balance}** in your wallet.`); } if (command === 'weekly') { let weeklyAmount = 7500; let cooldown = 604800000; // 7 days in ms let lastWeekly = await db.get(`lastWeekly_${message.author.id}`) || 0; if (Date.now() - lastWeekly < cooldown) { let timeRemaining = cooldown - (Date.now() - lastWeekly); let days = Math.floor(timeRemaining / 86400000); let hours = Math.floor((timeRemaining % 86400000) / 3600000); return message.reply(`ā³ Too soon! Your next weekly chest opens in **${days}d ${hours}h**.`); } await db.add(`wallet_${message.author.id}`, weeklyAmount); await db.set(`lastWeekly_${message.author.id}`, Date.now()); return message.reply(`šŸ”± **Weekly Treasure!** Midas has granted you a massive **$${weeklyAmount}**!`); } if (command === 'daily') { let dailyAmount = 1000; let cooldown = 86400000; // 24 hours in ms let lastDaily = await db.get(`lastDaily_${message.author.id}`) || 0; if (Date.now() - lastDaily < cooldown) { let timeRemaining = cooldown - (Date.now() - lastDaily); let hours = Math.floor(timeRemaining / 3600000); let minutes = Math.floor((timeRemaining % 3600000) / 60000); return message.reply(`ā³ Midas has already blessed you today! Come back in **${hours}h ${minutes}m**.`); } await db.add(`wallet_${message.author.id}`, dailyAmount); await db.set(`lastDaily_${message.author.id}`, Date.now()); return message.reply(`šŸ’° **Daily Reward!** Midas gives you **$${dailyAmount}**. Check back tomorrow!`); } // 2. !beg if (command === 'beg') { let timeout = 300000; let lastBeg = await db.get(`lastBeg_${message.author.id}`); let multiplier = 1; let doubleUntil = await db.get(`double_until_${message.author.id}`) || 0; if (doubleUntil > Date.now()) multiplier = 2; let amount = Math.floor(Math.random() * 100) + 50; let finalAmount = amount * multiplier; if (lastBeg !== null && timeout - (Date.now() - lastBeg) > 0) { let timeRemaining = timeout - (Date.now() - lastBeg); let minutes = Math.floor(timeRemaining / 60000); let seconds = ((timeRemaining % 60000) / 1000).toFixed(0); return message.reply(`šŸ¤ Midas is tired of your begging! Come back in **${minutes}m ${seconds}s**.`); } else { await db.add(`wallet_${message.author.id}`, finalAmount); await db.set(`lastBeg_${message.author.id}`, Date.now()); let msg = `šŸ’° You begged and got **$${finalAmount}**`; if (multiplier === 2) msg += " **(2X BOOST ACTIVE!)**"; return message.reply(msg); } } // 3. !work if (command === 'work') { let timeout = 600000; let lastWork = await db.get(`lastWork_${message.author.id}`); if (lastWork !== null && timeout - (Date.now() - lastWork) > 0) { let timeRemaining = timeout - (Date.now() - lastWork); let minutes = Math.floor(timeRemaining / 60000); let seconds = ((timeRemaining % 60000) / 1000).toFixed(0); return message.reply(`šŸ›‘ Midas says you're tired! Please wait **${minutes}m ${seconds}s** before working again.`); } else { let amount = Math.floor(Math.random() * 200) + 50; await db.add(`wallet_${message.author.id}`, amount); await db.set(`lastWork_${message.author.id}`, Date.now()); return message.reply(`āš’ļø You worked at the gold mines and earned **$${amount}**!`); } } // 4. !rob if (command === 'rob') { let target = message.mentions.users.first(); if (!target) return message.reply("Who are you trying to rob? Mention them!"); if (target.id === message.author.id) return message.reply("You can't rob yourself..."); // --- COOLDOWN LOGIC START --- let cooldown = 120000; // 2 minutes in milliseconds let lastRob = await db.get(`robCD_${message.author.id}`); if (lastRob !== null && cooldown - (Date.now() - lastRob) > 0) { let timeObj = cooldown - (Date.now() - lastRob); let seconds = Math.floor(timeObj / 1000); return message.reply(`šŸš“ The police are watching! Wait **${seconds} seconds** before your next heist.`); } // --- COOLDOWN LOGIC END --- let authorWallet = await db.get(`wallet_${message.author.id}`) || 0; let targetWallet = await db.get(`wallet_${target.id}`) || 0; if (targetWallet <= 0) return message.reply("This person has $0. There's nothing to steal!"); // Shield Check let targetShields = await db.get(`shield_${target.id}`) || 0; if (targetShields > 0) { await db.set(`robCD_${message.author.id}`, Date.now()); // Sets cooldown even if failed await db.sub(`shield_${target.id}`, 1); return message.reply(`šŸ›”ļø **FAILED!** ${target.username} was protected by a shield! They have ${targetShields - 1} shields left.`); } // Rob Logic let chance = Math.random() < 0.5; await db.set(`robCD_${message.author.id}`, Date.now()); // Set the cooldown timestamp if (chance) { let stolenAmount = Math.floor(Math.random() * targetWallet) + 1; await db.sub(`wallet_${target.id}`, stolenAmount); await db.add(`wallet_${message.author.id}`, stolenAmount); return message.reply(`šŸ’ø **SUCCESS!** You robbed **${target.username}** and made off with **$${stolenAmount.toLocaleString()}**!`); } else { let fine = 1000; if (authorWallet < fine) fine = authorWallet; if (fine > 0) { await db.sub(`wallet_${message.author.id}`, fine); await db.add(`wallet_${target.id}`, fine); return message.reply(`šŸš“ **BUSTED!** You got caught trying to rob **${target.username}** and paid them a fine of **$${fine.toLocaleString()}**!`); } else { return message.reply(`šŸš“ **BUSTED!** You got caught trying to rob **${target.username}**! Luckily, you're too broke to pay a fine.`); } } } if (command === 'give' || command === 'pay') { let user = message.mentions.users.first(); let amount = parseInt(args[1]); // Assuming 'm.give @user 100' let balance = await db.get(`wallet_${message.author.id}`) || 0; if (!user) return message.reply("Who are you trying to give money to? Mention them!"); if (user.id === message.author.id) return message.reply("You can't give money to yourself!"); if (!amount || isNaN(amount) || amount <= 0) return message.reply("Please enter a valid amount of gold."); if (amount > balance) return message.reply("You don't have enough gold in your wallet!"); // Transfer the gold await db.sub(`wallet_${message.author.id}`, amount); await db.add(`wallet_${user.id}`, amount); return message.reply(`āœ… Successfully sent **$${amount}** to **${user.username}**!`); } // 5. !bank commands if (command === 'bank') { let bankBal = await db.get(`bank_${message.author.id}`) || 0; let bankLvl = await db.get(`bankLvl_${message.author.id}`) || 0; let maxCapacity = 2500 + (bankLvl * 2500); return message.reply(`šŸ¦ **Midas Bank**\nBalance: **$${bankBal} / $${maxCapacity}**\nLevel: **${bankLvl}**`); } if (command === 'dep' || command === 'deposit') { let amount = parseInt(args[0]); let wallet = await db.get(`wallet_${message.author.id}`) || 0; let bankBal = await db.get(`bank_${message.author.id}`) || 0; let bankLvl = await db.get(`bankLvl_${message.author.id}`) || 0; let maxCapacity = 2500 + (bankLvl * 2500); if (!amount || amount <= 0 || amount > wallet) return message.reply("Invalid amount."); if (bankBal + amount > maxCapacity) return message.reply("Bank is full!"); await db.sub(`wallet_${message.author.id}`, amount); await db.add(`bank_${message.author.id}`, amount); return message.reply(`Deposited **$${amount}**.`); } if (command === 'withdraw' || command === 'with') { let amount = args[0]; let bankBal = await db.get(`bank_${message.author.id}`) || 0; // Handle "all" keyword if (amount === 'all') amount = bankBal; else amount = parseInt(amount); // Safety Checks if (!amount || isNaN(amount) || amount <= 0) return message.reply("Enter a valid amount to withdraw."); if (amount > bankBal) return message.reply(`You only have **$${bankBal}** in your bank!`); // Move the money await db.sub(`bank_${message.author.id}`, amount); await db.add(`wallet_${message.author.id}`, amount); return message.reply(`šŸ¦ You withdrew **$${amount}** from your bank.`); } if (command === 'bankupg' || (command === 'bank' && args[0] === 'upg')) { let confirmed = args.includes('yes'); let wallet = await db.get(`wallet_${message.author.id}`) || 0; let bankLvl = await db.get(`bankLvl_${message.author.id}`) || 0; let upgradeCost = 10000 + (bankLvl * 5000); if (wallet < upgradeCost) return message.reply(`āŒ Needs **$${upgradeCost}**!`); if (!confirmed) return message.reply(`āš ļø Cost: **$${upgradeCost}**. Type \`m.bankupg yes\` to confirm!`); await db.sub(`wallet_${message.author.id}`, upgradeCost); await db.add(`bankLvl_${message.author.id}`, 1); return message.reply(`šŸ“ˆ Bank Upgraded!`); } if (command === 'profile' || command === 'p') { try { let target = message.mentions.users.first() || message.author; // Fetch all data points let wallet = await db.get(`wallet_${target.id}`) || 0; let bank = await db.get(`bank_${target.id}`) || 0; let lvl = await db.get(`lvl_${target.id}`) || 0; let xp = await db.get(`xp_${target.id}`) || 0; let shields = await db.get(`shield_${target.id}`) || 0; // Fetch shield count let needed = (lvl + 1) * 100; const profileEmbed = new EmbedBuilder() .setColor('#FFD700') .setTitle(`šŸ”± ${target.username}'s Profile`) .setThumbnail(target.displayAvatarURL({ dynamic: true })) .addFields( { name: "šŸ’° Wallet", value: `$${wallet.toLocaleString()}`, inline: true }, { name: "šŸ¦ Bank", value: `$${bank.toLocaleString()}`, inline: true }, { name: "šŸ›”ļø Shields", value: `${shields} Active`, inline: true }, { name: "⭐ Level", value: `Lvl ${lvl}`, inline: true }, { name: "šŸ“ˆ Experience", value: `${xp} / ${needed} XP`, inline: true } ) .setFooter({ text: "Buy shields in the shop or find them in crates!" }) .setTimestamp(); return message.reply({ embeds: [profileEmbed] }); } catch (error) { console.error(error); return message.reply("āŒ **Error:** Profile could not be loaded. Ensure your database keys are correct!"); } } // 6. !shop if (command === 'shop') { const shopEmbed = new EmbedBuilder() .setColor('#FFD700') .setTitle('šŸ›’ Midas Official Shop') .setDescription('Use `m.buy [item name]` to purchase.') .addFields( { name: 'šŸ“¦ Mystery Crates', value: '`Uncommon Crate` — **$1,000**\n`Rare Crate` — **$2,500**\n`Epic Crate` — **$10,000**', inline: false }, { name: 'šŸŽ£ Fishing Gear', value: '`Old Fishing Rod` — **$500**\n`Good Fishing Rod` — **$5,000**\n`Epic Fishing Rod` — **$25,000**', inline: false }, { name: 'šŸ›”ļø Protection', value: '`Shield` — **$500**', inline: false } ) .setFooter({ text: 'Midas Economy • Prices updated' }); return message.reply({ embeds: [shopEmbed] }); } // 7. !buy if (command === 'buy') { let item = args.join(" ").toLowerCase(); let wallet = await db.get(`wallet_${message.author.id}`) || 0; if (!item) return message.reply("What do you want to buy? Example: `m.buy shield` balance"); const items = { "uncommon crate": 1000, "rare crate": 2500, "epic crate": 10000, "old fishing rod": 500, "good fishing rod": 5000, "epic fishing rod": 25000, "shield": 2000 }; let cost = items[item]; if (!cost) return message.reply("That item isn't in the shop!"); if (wallet < cost) { return message.reply(`āŒ You need **$${(cost - wallet).toLocaleString()}** more for that.`); } // --- SHIELD LIMIT CHECK --- if (item === "shield") { let currentShields = await db.get(`shield_${message.author.id}`) || 0; if (currentShields >= 15) { return message.reply("šŸ›”ļø Your shield slot is full! (**15/15**). Use some before buying more."); } await db.sub(`wallet_${message.author.id}`, cost); await db.add(`shield_${message.author.id}`, 1); return message.reply(`šŸ›”ļø You bought a **Shield**! Protection: **${currentShields + 1}/15**.`); } // --- DEFAULT BUY LOGIC (Rods/Crates) --- await db.sub(`wallet_${message.author.id}`, cost); let formattedName = item.split(' ').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' '); await db.push(`items_${message.author.id}`, formattedName); return message.reply(`šŸ›ļø You bought a **${formattedName}** for **$${cost.toLocaleString()}**.`); } // 8. !inventory if (command === 'inventory' || command === 'inv') { let items = await db.get(`items_${message.author.id}`) || []; if (items.length === 0) return message.reply("Your inventory is empty! Go buy something at the shop."); // This part groups items so it says "Uncommon Crate x2" instead of listing it twice let displayItems = {}; items.forEach(item => { displayItems[item] = (displayItems[item] || 0) + 1; }); let itemList = Object.keys(displayItems).map(name => `**${name}** x${displayItems[name]}`).join("\n"); const invEmbed = new EmbedBuilder() .setColor('#FFD700') .setTitle(`šŸŽ’ ${message.author.username}'s Inventory`) .setDescription(itemList); return message.reply({ embeds: [invEmbed] }); } // 9. !use if (command === 'use' || command === 'open') { let item = args.join(" ").toLowerCase(); let inv = await db.get(`items_${message.author.id}`) || []; let itemIndex = inv.findIndex(i => i.toLowerCase() === item); if (itemIndex === -1) return message.reply("āŒ You don't have this item!"); // Remove item from inventory inv.splice(itemIndex, 1); await db.set(`items_${message.author.id}`, inv); let rng = Math.random() * 100; let currentShields = await db.get(`shield_${message.author.id}`) || 0; // Helper function to add shields without going over 15 async function addShields(amt) { let newTotal = currentShields + amt; if (newTotal > 15) newTotal = 15; await db.set(`shield_${message.author.id}`, newTotal); return newTotal; } // --- UNCOMMON CRATE --- if (item === "uncommon crate") { if (rng < 50) { let total = await addShields(1); return message.reply(`šŸŽ Got a **Shield**! Current: **${total}/15**`); } else if (rng < 75) { let total = await addShields(2); return message.reply(`šŸŽ Got a **Better Shield**! Current: **${total}/15**`); } else if (rng < 87.5) { await db.set(`double_until_${message.author.id}`, Date.now() + 1800000); return message.reply("šŸŽ Got **30m Double Cash**!"); } else { await db.add(`wallet_${message.author.id}`, 2000); return message.reply("šŸŽ Got **$2,000**!"); } } // --- RARE CRATE --- if (item === "rare crate") { if (rng < 50) { let total = await addShields(2); return message.reply(`šŸŽ Got a **Better Shield**! Current: **${total}/15**`); } else if (rng < 75) { let total = await addShields(3); return message.reply(`šŸŽ Got a **Legend Shield**! Current: **${total}/15**`); } else if (rng < 87) { await db.add(`wallet_${message.author.id}`, 5000); return message.reply("šŸŽ Got **$5,000 Cash**!"); } else if (rng < 96.5) { await db.push(`items_${message.author.id}`, "Epic Crate"); return message.reply("šŸŽ **LUCKY!** You found an **Epic Crate** inside!"); } else { await db.add(`wallet_${message.author.id}`, 25000); return message.reply("šŸŽ **HUGE WIN!** Found **$25,000 Cash**!"); } } // --- EPIC CRATE --- if (item === "epic crate") { if (rng < 50) { for(let i=0; i<5; i++) await db.push(`items_${message.author.id}`, "Uncommon Crate"); return message.reply("šŸŽ Found **5 Uncommon Crates**!"); } else if (rng < 70) { for(let i=0; i<4; i++) await db.push(`items_${message.author.id}`, "Rare Crate"); return message.reply("šŸŽ Found **4 Rare Crates**!"); } else if (rng < 85) { let total = await addShields(9); return message.reply(`šŸŽ Got **3 Legend Shields**! Current: **${total}/15**`); } else if (rng < 95) { await db.add(`wallet_${message.author.id}`, 20000); return message.reply("šŸŽ Found **$20,000 Cash**!"); } else { let bal = await db.get(`wallet_${message.author.id}`) || 0; let win = bal > 50000 ? bal : 50000; await db.add(`wallet_${message.author.id}`, win); return message.reply(`šŸ”„ **JACKPOT!** Your money was doubled! (Gained **$${win.toLocaleString()}**)`); } } return message.reply("That item doesn't have a function!"); } // 10. !lb if (command === 'lb' || command === 'leaderboard') { let type = args[0]?.toLowerCase(); let allData = await db.all(); let leaderboard = []; let title = ""; if (type === 'level' || type === 'lvl') { // --- LEVEL LEADERBOARD --- leaderboard = allData.filter(data => data.id.startsWith('lvl_')); title = "⭐ Global Level Leaderboard"; } else { // --- MONEY LEADERBOARD (Default) --- leaderboard = allData.filter(data => data.id.startsWith('wallet_')); title = type === 'global' ? "šŸŒ Global Wealth" : "šŸ  Server Wealth"; // Filter for server if not global if (type !== 'global') { leaderboard = leaderboard.filter(data => { let userId = data.id.split('_')[1]; return message.guild.members.cache.has(userId); }); } } // Sort and Slice leaderboard.sort((a, b) => b.value - a.value); leaderboard = leaderboard.slice(0, 10); let content = ""; for (let i = 0; i < leaderboard.length; i++) { let userId = leaderboard[i].id.split('_')[1]; let user = await client.users.fetch(userId).catch(() => null); let name = user ? user.username : "Unknown User"; // Format based on type let valueLabel = (type === 'level' || type === 'lvl') ? `Lvl ${leaderboard[i].value}` : `$${leaderboard[i].value.toLocaleString()}`; content += `**${i + 1}.** ${name} — **${valueLabel}**\n`; } const lbEmbed = new EmbedBuilder() .setColor('#FFD700') .setTitle(title) .setDescription(content || "No data found yet!") .setFooter({ text: "Midas Rankings" }); return message.reply({ embeds: [lbEmbed] }); } if (command === 'lotto' || command === 'lottery') { let amount = parseInt(args[0]); let wallet = await db.get(`wallet_${message.author.id}`) || 0; // Show Current Pot if no amount is provided if (!amount) { let totalPot = await db.get(`lotto_total`) || 0; return message.reply(`šŸŽ« **Midas Lottery**\nTotal Pot: **$${totalPot.toLocaleString()}**\nUse \`m.lotto [amount]\` to buy tickets. More gold = higher chance!`); } // Checks if (isNaN(amount) || amount <= 0) return message.reply("Please enter a valid amount to bet."); if (amount > wallet) return message.reply("You don't have enough gold!"); // Update Wallet await db.sub(`wallet_${message.author.id}`, amount); // Update Lottery Data await db.add(`lotto_total`, amount); // Store user tickets (e.g., if they give 100 gold, they get 100 entries) let userTickets = await db.get(`lotto_user_${message.author.id}`) || 0; await db.set(`lotto_user_${message.author.id}`, userTickets + amount); // Add user ID to the entrants list if not already there let entrants = await db.get(`lotto_entrants`) || []; if (!entrants.includes(message.author.id)) { entrants.push(message.author.id); await db.set(`lotto_entrants`, entrants); } return message.reply(`šŸŽŸļø You bought **${amount.toLocaleString()}** tickets! Good luck.`); } // --- HELP COMMAND --- if (command === 'help') { const helpEmbed = new EmbedBuilder() .setColor('#FFD700') .setTitle("šŸ”± Midas Bot Help Menu") .addFields( { name: "šŸ’° Economy", value: "`bal`, `beg`, `work`, `daily`, `cf`, `give`, `lb`" }, { name: "šŸ¦ Banking", value: "`bank`, `dep`, `with`, `bankupg`" }, { name: "šŸ›’ Shop", value: "`shop`, `buy`, `inv`, `use`" }, { name: "🄷 Crime", value: "`rob`" } ) .setFooter({ text: "Midas • 2026" }); return message.reply({ embeds: [helpEmbed] }); } // --- GIVE COMMAND --- if (command === 'give' || command === 'pay') { let user = message.mentions.users.first(); let amount = parseInt(args[1]); let balance = await db.get(`wallet_${message.author.id}`) || 0; if (!user) return message.reply("Mention someone to give money to!"); if (user.id === message.author.id) return message.reply("You can't give money to yourself!"); if (!amount || isNaN(amount) || amount <= 0) return message.reply("Enter a valid amount."); if (amount > balance) return message.reply("You don't have enough gold!"); await db.sub(`wallet_${message.author.id}`, amount); await db.add(`wallet_${user.id}`, amount); return message.reply(`āœ… Sent **$${amount}** to **${user.username}**!`); } if (command === 'inv' || command === 'inventory') { let inv = await db.get(`inv_${message.author.id}`) || {}; let items = Object.keys(inv).filter(item => inv[item] > 0); if (items.length === 0) return message.reply("Your inventory is empty!"); let list = items.map(item => `**${item}**: x${inv[item]}`).join("\n"); return message.reply(`šŸŽ’ **Your Inventory:**\n${list}`); } // --- USE COMMAND --- if (command === 'use') { let item = args.join(" ").toLowerCase(); let inv = await db.get(`inv_${message.author.id}`) || {}; if (!inv[item] || inv[item] < 1) return message.reply("You don't have this item!"); inv[item] -= 1; await db.set(`inv_${message.author.id}`, inv); let rng = Math.random() * 100; // Example logic for a crate if (item === "uncommon crate") { await db.add(`wallet_${message.author.id}`, 1000); return message.reply("šŸŽ You used an Uncommon Crate and found **$1,000**!"); } return message.reply(`You used **${item}** but nothing happened.`); } // --- SLOTS COMMAND --- if (command === 'slots' || command === 'sl') { let bet = parseInt(args[0]); let wallet = await db.get(`wallet_${message.author.id}`) || 0; // 1. --- 15s COOLDOWN --- let cooldown = 15000; let lastSlots = await db.get(`slotsCooldown_${message.author.id}`); if (lastSlots !== null && cooldown - (Date.now() - lastSlots) > 0) { let timeRemaining = (cooldown - (Date.now() - lastSlots)) / 1000; return message.reply(`šŸŽ° **Wait!** try again in **${timeRemaining.toFixed(1)}s**.`); } // 2. --- CHECKS --- if (!bet || isNaN(bet) || bet <= 0) return message.reply("Usage: `m.slots [amount]`"); if (bet > wallet) return message.reply("You don't have enough gold!"); await db.set(`slotsCooldown_${message.author.id}`, Date.now()); // 3. --- SMALLER EMOJI POOL (Makes it cleaner) --- const slotItems = ["šŸ’Ž", "šŸ’°", "šŸ”„", "šŸ’", "šŸ””"]; // 5 items let s1 = slotItems[Math.floor(Math.random() * slotItems.length)]; let s2 = slotItems[Math.floor(Math.random() * slotItems.length)]; let s3 = slotItems[Math.floor(Math.random() * slotItems.length)]; // 4. --- WIN ONLY ON 3 MATCHES --- let win = (s1 === s2 && s2 === s3); let multiplier = 10; // High payout since it's hard to get 3 matching if (win) { let prize = bet * multiplier; await db.add(`wallet_${message.author.id}`, prize); const winEmbed = new EmbedBuilder() .setColor('#00FF00') .setTitle('šŸŽ° MIDAS SLOTS') .setDescription(`**[ ${s1} | ${s2} | ${s3} ]**\n\n**JACKPOT!** You won **$${prize.toLocaleString()}**!`) .setFooter({ text: "All 3 matched! 10x Payout" }); return message.reply({ embeds: [winEmbed] }); } else { await db.sub(`wallet_${message.author.id}`, bet); const loseEmbed = new EmbedBuilder() .setColor('#FF0000') .setTitle('šŸŽ° MIDAS SLOTS') .setDescription(`**[ ${s1} | ${s2} | ${s3} ]**\n\nYou lost **$${bet.toLocaleString()}**.`) .setFooter({ text: "Better luck next time!" }); return message.reply({ embeds: [loseEmbed] }); } } if (command === 'coinflip' || command === 'cf') { let choice = args[0]?.toLowerCase(); let bet = parseInt(args[1]); let wallet = await db.get(`wallet_${message.author.id}`) || 0; // Safety Checks if (!['heads', 'tails'].includes(choice)) return message.reply("Pick `heads` or `tails`! Example: `m.cf heads 100`."); if (isNaN(bet) || bet <= 0) return message.reply("Please enter a valid amount to bet."); if (bet > wallet) return message.reply(`You only have **$${wallet}**. You can't bet more than you own!`); let result = Math.random() < 0.5 ? 'heads' : 'tails'; if (choice === result) { await db.add(`wallet_${message.author.id}`, bet); return message.reply(`šŸŖ™ It was **${result}**! You won **$${bet}**!`); } else { await db.sub(`wallet_${message.author.id}`, bet); return message.reply(`šŸŖ™ It was **${result}**... You lost **$${bet}**.`); } } if (command === 'addmoney') { // Replace 'YOUR_USER_ID' with your actual Discord User ID const ownerID = '1211718253777260666'; if (message.author.id !== ownerID) { return message.reply("āŒ Only the King Midas (Owner) can use this command!"); } let user = message.mentions.users.first() || message.author; let amount = parseInt(args[1]) || parseInt(args[0]); if (!amount || isNaN(amount)) return message.reply("Usage: `m.addmoney [amount]` or `m.addmoney @user [amount]`"); await db.add(`wallet_${user.id}`, amount); return message.reply(`šŸ”± **Midas Touch!** Added **$${amount.toLocaleString()}** to ${user.username}'s wallet.`); } if (command === 'deleteitem' || command === 'removeitem') { // 1. SECURITY: Only the owner can run this const ownerID = "1211718253777260666"; if (message.author.id !== ownerID) { return message.reply("āŒ **Access Denied:** Only the Midas Owner can use this command."); } // 2. PARSE: Get the user and the item name let target = message.mentions.users.first(); let itemName = args.slice(1).join(" "); // Everything after the mention if (!target || !itemName) { return message.reply("Usage: `m.deleteitem @user [item name]`"); } // 3. DATABASE: Get their items let inv = await db.get(`items_${target.id}`) || []; // 4. LOGIC: Find and remove ONE instance of the item // We use case-insensitive search so "Epic Crate" matches "epic crate" let itemIndex = inv.findIndex(i => i.toLowerCase() === itemName.toLowerCase()); if (itemIndex === -1) { return message.reply(`āŒ That user doesn't have a **${itemName}** in their inventory.`); } let removedItem = inv[itemIndex]; // Save the name for the message inv.splice(itemIndex, 1); await db.set(`items_${target.id}`, inv); return message.reply(`šŸ—‘ļø Successfully removed **1x ${removedItem}** from **${target.username}**'s inventory.`); } if (command === 'setshield') { // 1. Owner Check const ownerID = "1211718253777260666"; if (message.author.id !== ownerID) return message.reply("āŒ This is an Owner-Only command."); // 2. Parse User and Amount let target = message.mentions.users.first(); let amount = parseInt(args[1]); if (!target || isNaN(amount)) { return message.reply("Usage: `m.setshield @user [amount]`"); } // 3. Logic: Cap at 15 or allow owner to bypass? // Usually, owners bypass limits, but let's keep it 15 for safety. if (amount > 15) amount = 15; if (amount < 0) amount = 0; await db.set(`shield_${target.id}`, amount); return message.reply(`šŸ›”ļø **Admin Update:** Set **${target.username}'s** shields to **${amount}/15**.`); } }); // Closes messageCreate // Helper function setInterval(async () => { const totalPot = await db.get('lottery_pot') || 0; const participants = await db.get('lottery_participants') || []; if (participants.length > 0 && totalPot > 0) { // Pick the winner const winnerId = participants[Math.floor(Math.random() * participants.length)]; // Add money to winner await db.add(`wallet_${winnerId}`, totalPot); // --- THE MESSAGE LOGIC --- // Replace 'CHANNEL_ID_HERE' with the ID of your lottery channel const channel = await client.channels.fetch('1462781905429729414').catch(() => null); if (channel) { const winEmbed = new EmbedBuilder() .setColor('#FFD700') .setTitle('šŸŽ‰ LOTTERY RESULTS!') .setDescription(`The 24-hour drawing has ended!\n\nšŸ‘‘ Winner: <@${winnerId}>\nšŸ’° Grand Prize: **$${totalPot.toLocaleString()}**`) .setFooter({ text: 'A new round starts now! Use m.lotto to join.' }) .setTimestamp(); channel.send({ content: `<@${winnerId}>`, embeds: [winEmbed] }); } // Reset the lottery await db.set('lottery_pot', 0); await db.set('lottery_participants', []); } }, 86400000); // 24 Hours mongoose.connect(process.env.MONGO_URI).then(() => { console.log("Connected to MongoDB!"); client.login(process.env.MTQ2MDIyOTc4OTUzMjAzMzA4NQ.GlByyF.jtNrYtQN8AoZaXBjxmWNnaka-K7cfLF6w8EgSE); }).catch(err => console.error("Database Error:", err)); // MTQ2MDIyOTc4OTUzMjAzMzA4NQ.GlByyF.jtNrYtQN8AoZaXBjxmWNnaka-K7cfLF6w8EgSE