// code from goatstore // api: https://store.agi.bd const cooldowns = new Map(); module.exports = { config: { name: "coin", version: "3.0", author: "NIROB", countDown: 10, shortDescription: { en: "šŸŖ™ Flip a coin and test your luck!" }, longDescription: { en: "Choose heads or tails and see if luck is on your side šŸ’«" }, category: "game" }, langs: { en: { invalid: "āš ļø š—Øš˜€š—®š—“š—²: /š—°š—¼š—¶š—» <š—®š—ŗš—¼š˜‚š—»š˜> <š—µš—²š—®š—±/š˜š—®š—¶š—¹>", not_money: "šŸ’ø š—¬š—¼š˜‚ š—±š—¼š—»'š˜ š—µš—®š˜ƒš—² š—²š—»š—¼š˜‚š—“š—µ š—ŗš—¼š—»š—²š˜† 😿", win: "šŸŖ™ š‚šØš¢š§ šŸš„š¢š©š©šžš → **%1**\nšŸŽ‰ š˜šØš® š°šØš§ **$%2** šŸ’°", lose: "šŸŖ™ š‚šØš¢š§ šŸš„š¢š©š©šžš → **%1**\nšŸ’” š˜šØš® š„šØš¬š­ **$%1** 😿" } }, onStart: async function ({ args, message, event, usersData, getLang }) { const { senderID } = event; if (args.length < 2) return message.reply(getLang("invalid")); const amount = parseInt(args[0]); const choice = args[1].toLowerCase(); if (!["head", "tail", "heads", "tails"].includes(choice)) return message.reply(getLang("invalid")); if (isNaN(amount) || amount <= 0) return message.reply(getLang("invalid")); const userData = await usersData.get(senderID); if (amount > userData.money) return message.reply(getLang("not_money")); const side = Math.random() < 0.5 ? "head" : "tail"; const won = side.startsWith(choice.slice(0, 1)); const winAmount = won ? amount * 2 : -amount; const msg = won ? getLang("win", side, formatMoney(winAmount)) : getLang("lose", side, formatMoney(amount)); await usersData.set(senderID, { money: userData.money + winAmount, data: userData.data }); return message.reply(msg); } }; function formatMoney(a) { if (a >= 1e9) return (a / 1e9).toFixed(2) + "š—•"; if (a >= 1e6) return (a / 1e6).toFixed(2) + "šŒ"; if (a >= 1e3) return (a / 1e3).toFixed(2) + "š—ž"; return a.toString(); }