// code from goatstore // api: https://store.agi.bd const fs = require("fs-extra"); const path = require("path"); module.exports = { config: { name: "delfile", aliases: ["delcmd", "rm"], version: "2.0", author: "𝐑𝐀𝐘𝐇𝐀𝐍-𝐒𝐀𝐁𝐁𝐈𝐑", countDown: 3, role: 2, category: "owner", guide: { en: "{pn} \nEx: {pn} auto\n{pn} sad2" } }, onStart: async function ({ api, event, args }) { const { threadID, messageID } = event; if (!args[0]) { return api.sendMessage("⚠️ Usage: delfile \nEx: delfile auto", threadID, messageID); } const inputName = args[0].toLowerCase(); // GoatBot থেকে সব কমান্ড লিস্ট নিবে const allCommands = global.GoatBot.commands; let targetFile = null; let realName = null; // ১. সরাসরি নামে খোঁজা if (allCommands.has(inputName)) { const cmd = allCommands.get(inputName); // ফাইলের আসল পাথ বের করা targetFile = cmd.filePath || path.join(__dirname, `${cmd.config.name}.js`); realName = cmd.config.name; } else { // ২. alias দিয়ে খোঁজা (যেমন autoreply -> auto) for (const [name, cmd] of allCommands) { if (cmd.config.aliases && cmd.config.aliases.includes(inputName)) { targetFile = cmd.filePath || path.join(__dirname, `${name}.js`); realName = name; break; } } } // ৩. যদি তাও না পায়, ফাইল নাম হিসাবে ট্রাই করবে if (!targetFile) { let fileName = inputName; if (!fileName.endsWith(".js")) fileName += ".js"; targetFile = path.join(__dirname, fileName); realName = fileName; } try { if (!fs.existsSync(targetFile)) { // শেষ চেষ্টা: __dirname এ auto.js আছে কিনা const directPath = path.join(__dirname, `${inputName}.js`); if (fs.existsSync(directPath)) { targetFile = directPath; } else { return api.sendMessage(`❌ ফাইল পাওয়া যায়নি বস:\nTried: ${inputName}.js\nPath: ${targetFile}\n\n💡 cmd list লিখে নাম দেখো`, threadID, messageID); } } await fs.unlink(targetFile); return api.sendMessage( `✅ 𝐃𝐄𝐋𝐄𝐓𝐄𝐃\n━━━━━━━━━━\n📄 ${realName}\n📂 ${path.basename(targetFile)}\n👤 𝐑𝐀𝐘𝐇𝐀𝐍-𝐒𝐀𝐁𝐁𝐈𝐑\n━━━━━━━━━━\n♻️ Restart দাও`, threadID, messageID ); } catch (e) { return api.sendMessage(`❌ Error: ${e.message}\nPath: ${targetFile}`, threadID, messageID); } } };