const axios = require("axios"); module.exports = { config: { name: "cardgame", aliases: ["card", "cg", "higherlower"], version: "1.3", author: "Mehedi-saito", countDown: 8, role: 0, shortDescription: { en: "Beautiful Higher or Lower card game", vi: "Game bài Higher or Lower đẹp" }, description: { en: "Bet money on Higher or Lower with small beautiful cards", vi: "Cược Higher or Lower với ảnh bài nhỏ và đẹp" }, category: "game", guide: { en: "{pn} \nExample: {pn} 500", vi: "{pn} \nVí dụ: {pn} 500" } }, langs: { en: { missingAmount: "❌ Please enter bet amount\nExample: %1 500", invalidAmount: "❌ Invalid amount!", notEnough: "❌ Not enough money!\nBalance: %1$", minBet: "❌ Minimum bet is 50$", maxBet: "❌ Maximum bet is 50,000$", start: "🌸 ────────────── 🌸\n 🎴 𝐂𝐀𝐑𝐃 𝐆𝐀𝐌𝐄 🎴\n🌸 ────────────── 🌸\n\n🃏 Your Card:\n%1\n\n💰 Bet Amount: %2$\n\n━━━━━━━━━━━━━━\nReply:\n• higher / h\n• lower / l\n━━━━━━━━━━━━━━", win: "🌸 ────────────── 🌸\n 🎉 𝐘𝐎𝐔 𝐖𝐎𝐍! 🎉\n🌸 ────────────── 🌸\n\n🃏 First → %1\n🃏 Second → %2\n\n💰 You Won: %3\( \n💳 New Balance: %4 \)\n\n🌸 ────────────── 🌸", lose: "🌸 ────────────── 🌸\n 😢 𝐘𝐎𝐔 𝐋𝐎𝐒𝐓 😢\n🌸 ────────────── 🌸\n\n🃏 First → %1\n🃏 Second → %2\n\n💸 Lost: %3\( \n💳 Balance: %4 \)\n\n🌸 ────────────── 🌸", tie: "🌸 ────────────── 🌸\n 🤝 𝐈𝐓'𝐒 𝐀 𝐓𝐈𝐄 🤝\n🌸 ────────────── 🌸\n\n🃏 First → %1\n🃏 Second → %2\n\n💰 Bet Returned\n💳 Balance: %3$\n\n🌸 ────────────── 🌸", invalidReply: "⚠️ Please reply only:\nhigher / h or lower / l" }, vi: { missingAmount: "❌ Vui lòng nhập số tiền cược\nVí dụ: %1 500", invalidAmount: "❌ Số tiền không hợp lệ!", notEnough: "❌ Không đủ tiền!\nSố dư: %1$", minBet: "❌ Cược tối thiểu 50$", maxBet: "❌ Cược tối đa 50,000$", start: "🌸 ────────────── 🌸\n 🎴 𝐂𝐀𝐑𝐃 𝐆𝐀𝐌𝐄 🎴\n🌸 ────────────── 🌸\n\n🃏 Lá bài của bạn:\n%1\n\n💰 Số tiền cược: %2$\n\n━━━━━━━━━━━━━━\nTrả lời:\n• higher / h\n• lower / l\n━━━━━━━━━━━━━━", win: "🌸 ────────────── 🌸\n 🎉 𝐁Ạ𝐍 𝐓𝐇Ắ𝐍𝐆! 🎉\n🌸 ────────────── 🌸\n\n🃏 Lá 1 → %1\n🃏 Lá 2 → %2\n\n💰 Thắng: %3\( \n💳 Số dư mới: %4 \)\n\n🌸 ────────────── 🌸", lose: "🌸 ────────────── 🌸\n 😢 𝐁Ạ𝐍 𝐓𝐇𝐔𝐀 😢\n🌸 ────────────── 🌸\n\n🃏 Lá 1 → %1\n🃏 Lá 2 → %2\n\n💸 Thua: %3\( \n💳 Số dư: %4 \)\n\n🌸 ────────────── 🌸", tie: "🌸 ────────────── 🌸\n 🤝 𝐇Ò𝐀! 🤝\n🌸 ────────────── 🌸\n\n🃏 Lá 1 → %1\n🃏 Lá 2 → %2\n\n💰 Tiền cược trả lại\n💳 Số dư: %3$\n\n🌸 ────────────── 🌸", invalidReply: "⚠️ Chỉ trả lời:\nhigher / h hoặc lower / l" } }, onStart: async function ({ message, args, event, usersData, commandName, getLang }) { const { senderID } = event; const amount = parseInt(args[0]); if (!args[0]) return message.reply(getLang("missingAmount", commandName)); if (isNaN(amount) || amount <= 0) return message.reply(getLang("invalidAmount")); if (amount < 50) return message.reply(getLang("minBet")); if (amount > 50000) return message.reply(getLang("maxBet")); const userData = await usersData.get(senderID); const money = userData.money || 0; if (money < amount) return message.reply(getLang("notEnough", money)); const ranks = [ { name: "A", value: 14, code: "A" }, { name: "2", value: 2, code: "2" }, { name: "3", value: 3, code: "3" }, { name: "4", value: 4, code: "4" }, { name: "5", value: 5, code: "5" }, { name: "6", value: 6, code: "6" }, { name: "7", value: 7, code: "7" }, { name: "8", value: 8, code: "8" }, { name: "9", value: 9, code: "9" }, { name: "10", value: 10, code: "0" }, { name: "J", value: 11, code: "J" }, { name: "Q", value: 12, code: "Q" }, { name: "K", value: 13, code: "K" } ]; const suits = [ { emoji: "♠️", code: "S" }, { emoji: "♥️", code: "H" }, { emoji: "♦️", code: "D" }, { emoji: "♣️", code: "C" } ]; const firstRank = ranks[Math.floor(Math.random() * ranks.length)]; const firstSuit = suits[Math.floor(Math.random() * suits.length)]; const firstCode = firstRank.code + firstSuit.code; const firstCardName = `\( {firstRank.name} \){firstSuit.emoji}`; // Smaller card size using image proxy const firstImage = `https://images.weserv.nl/?url=deckofcardsapi.com/static/img/${firstCode}.png&w=130&h=180&fit=contain&output=png`; await usersData.set(senderID, { money: money - amount }); const form = { body: getLang("start", firstCardName, amount), attachment: await global.utils.getStreamFromURL(firstImage) }; const sent = await message.reply(form); global.GoatBot.onReply.set(sent.messageID, { commandName, author: senderID, amount, firstCardName, firstValue: firstRank.value, firstCode, messageID: sent.messageID }); }, onReply: async function ({ message, event, Reply, usersData, getLang }) { const { author, amount, firstCardName, firstValue, firstCode, messageID } = Reply; const { senderID, body } = event; if (senderID !== author) return; const choice = body.trim().toLowerCase(); const isHigher = ["higher", "h", "উঁচু", "উচু", "cao", "high"].includes(choice); const isLower = ["lower", "l", "নিচু", "thấp", "low"].includes(choice); if (!isHigher && !isLower) { return message.reply(getLang("invalidReply")); } const ranks = [ { name: "A", value: 14, code: "A" }, { name: "2", value: 2, code: "2" }, { name: "3", value: 3, code: "3" }, { name: "4", value: 4, code: "4" }, { name: "5", value: 5, code: "5" }, { name: "6", value: 6, code: "6" }, { name: "7", value: 7, code: "7" }, { name: "8", value: 8, code: "8" }, { name: "9", value: 9, code: "9" }, { name: "10", value: 10, code: "0" }, { name: "J", value: 11, code: "J" }, { name: "Q", value: 12, code: "Q" }, { name: "K", value: 13, code: "K" } ]; const suits = [ { emoji: "♠️", code: "S" }, { emoji: "♥️", code: "H" }, { emoji: "♦️", code: "D" }, { emoji: "♣️", code: "C" } ]; const secondRank = ranks[Math.floor(Math.random() * ranks.length)]; const secondSuit = suits[Math.floor(Math.random() * suits.length)]; const secondCode = secondRank.code + secondSuit.code; const secondCardName = `\( {secondRank.name} \){secondSuit.emoji}`; const secondValue = secondRank.value; // Smaller size for both cards const firstImage = `https://images.weserv.nl/?url=deckofcardsapi.com/static/img/${firstCode}.png&w=120&h=165&fit=contain&output=png`; const secondImage = `https://images.weserv.nl/?url=deckofcardsapi.com/static/img/${secondCode}.png&w=120&h=165&fit=contain&output=png`; const userData = await usersData.get(senderID); let newMoney = userData.money || 0; let resultText = ""; if (secondValue === firstValue) { newMoney += amount; await usersData.set(senderID, { money: newMoney }); resultText = getLang("tie", firstCardName, secondCardName, newMoney); } else if ((isHigher && secondValue > firstValue) || (isLower && secondValue < firstValue)) { const winAmount = amount * 2; newMoney += winAmount; await usersData.set(senderID, { money: newMoney }); resultText = getLang("win", firstCardName, secondCardName, winAmount, newMoney); } else { resultText = getLang("lose", firstCardName, secondCardName, amount, newMoney); } const form = { body: resultText, attachment: [ await global.utils.getStreamFromURL(firstImage), await global.utils.getStreamFromURL(secondImage) ] }; global.GoatBot.onReply.delete(messageID); return message.reply(form); } };