// code from goatstore // api: https://store.agi.bd const axios = require("axios"); module.exports = { config: { name: "hindi", aliases: ["hi", "tohindi"], version: "1.1.0", author: "nazrul", countDown: 5, role: 0, description: { en: "Translate any text to Hindi", vi: "Dịch văn bản sang tiếng Hindi" }, category: "media", guide: { en: "{pn} [text]\n{pn} (reply to a message)\n\nExample:\n{pn} Hello how are you?", vi: "{pn} [văn bản]\n{pn} (reply tin nhắn)" } }, langs: { en: { translated: "🍂🍂 %1 → Hindi 🍂🍂\n\n%2", noText: "Please provide text to translate or reply to a message!", error: "❌ Translation failed. Please try again later." }, vi: { translated: "🍂🍂 %1 → Hindi 🍂🍂\n\n%2", noText: "Vui lòng nhập văn bản cần dịch hoặc reply tin nhắn!", error: "❌ Dịch thất bại. Vui lòng thử lại sau." } }, onStart: async function ({ message, event, args, getLang }) { let text = ""; // ১. যদি রিপ্লাই করা হয় if (event.messageReply && event.messageReply.body) { text = event.messageReply.body; } // ২. সাধারণভাবে টেক্সট দিলে else if (args.length > 0) { text = args.join(" "); } // ৩. ব্যাকআপ (কিছু বটে args খালি থাকলে) else if (event.body) { // কমান্ড নাম বাদ দিয়ে বাকি অংশ নেয় const body = event.body; const commandName = this.config.name; const prefix = global.GoatBot?.config?.prefix || ""; // prefix + command সরিয়ে দেয় text = body .replace(new RegExp(`^\( {prefix} \){commandName}`, "i"), "") .replace(new RegExp(`^${prefix}(hi|tohindi)`, "i"), "") .trim(); } if (!text) { return message.reply(getLang("noText")); } try { const res = await axios.get("https://translate.googleapis.com/translate_a/single", { params: { client: "dict-chrome-ex", sl: "auto", tl: "hi", dt: "t", q: text }, timeout: 10000 }); const translatedText = res.data[0].map(item => item[0]).join(""); const fromLang = res.data[2] || "auto"; return message.reply(getLang("translated", fromLang, translatedText)); } catch (err) { console.error("Hindi Translate Error:", err.message); return message.reply(getLang("error")); } } };