const axios = require("axios"); const baseApiUrl = async () => { const base = await axios.get("https://raw.githubusercontent.com/mahmudx7/HINATA/main/baseApiUrl.json"); return base.data.mahmud; }; /** * @author Ajmaul * @author: do not delete it */ module.exports = { config: { name: "footballgame", aliases: ["football"], version: "1.8", author: "ajmaul", countDown: 10, role: 0, category: "game", guide: { en: "{pn}" } }, onReply: async function ({ api, event, Reply, usersData }) { try { const { footballNames, author, messageID } = Reply; const getCoin = 500; const getExp = 121; if (event.senderID !== author) { return api.sendMessage("𝐓𝐡𝐢𝐬 𝐢𝐬 𝐧𝐨𝐭 𝐲𝐨𝐮𝐫 𝐪𝐮𝐢𝐳 𝐛𝐚𝐛𝐲 >🐸", event.threadID, event.messageID); } // ডাবল রিওয়ার্ড আটকাতে সাথে সাথে onReply থেকে সরিয়ে দাও global.GoatBot.onReply.delete(messageID); const reply = (event.body || "").trim().toLowerCase(); const isCorrect = footballNames.some(name => name.toLowerCase() === reply); const userData = await usersData.get(event.senderID); await api.unsendMessage(messageID).catch(() => {}); if (isCorrect) { const currentMoney = Number(userData?.money) || 0; const currentExp = Number(userData?.exp) || 0; await usersData.set(event.senderID, { ...userData, money: currentMoney + getCoin, exp: currentExp + getExp }); return api.sendMessage( `✅ | Correct answer baby.\nYou have earned ${getCoin} coins and ${getExp} exp.`, event.threadID, event.messageID ); } else { return api.sendMessage( `❌ | Wrong Answer baby.\nCorrect answer was: ${footballNames.join(" / ")}`, event.threadID, event.messageID ); } } catch (err) { console.log("Footballgame onReply error:", err); return api.sendMessage(`× Error: ${err.message}`, event.threadID, event.messageID); } }, onStart: async function ({ api, event, usersData }) { try { const { senderID } = event; const apiUrl = await baseApiUrl(); const response = await axios.get(`${apiUrl}/api/football`); const { name, imgurLink } = response.data.football; const footballNames = Array.isArray(name) ? name : [name]; const imageStream = await axios({ url: imgurLink, method: "GET", responseType: "stream", headers: { 'User-Agent': 'Mozilla/5.0' } }); api.sendMessage( { body: "A famous footballer has appeared! Guess their name.", attachment: imageStream.data }, event.threadID, (err, info) => { if (err || !info) return; global.GoatBot.onReply.set(info.messageID, { commandName: this.config.name, type: "reply", messageID: info.messageID, author: senderID, footballNames }); setTimeout(() => { global.GoatBot.onReply.delete(info.messageID); api.unsendMessage(info.messageID).catch(() => {}); }, 40000); }, event.messageID ); } catch (error) { console.error("Error:", error.message); api.sendMessage("🥹error, contact Aizen.", event.threadID, event.messageID); } } };