const { config } = global.GoatBot; module.exports = { config: { name: "wl", version: "2.1", author: "ajmaul", countDown: 5, role: 2, longDescription: { en: "Add, remove, edit whiteListIds (whitelist mode is always ON and cannot be disabled)" }, category: "owner", guide: { en: ' {pn} [add | -a] : Add whiteList role for user' + '\n {pn} [remove | -r] : Remove whiteList role of user' + '\n {pn} [list | -l]: List all whiteListIds' } }, langs: { en: { added: "✅ | Added whiteList role for %1 users:\n%2", alreadyWhiteList: "\n⚠ | %1 users already have whiteList role:\n%2", missingIdAdd: "⚠ | Please enter ID or tag user to add in whiteListIds", removed: "✅ | Removed whiteList role of %1 users:\n%2", notWhiteList: "⚠ | %1 users don't have whiteList role:\n%2", missingIdRemove: "⚠ | Please enter ID or tag user to remove from whiteListIds", listWhiteList: "👑 | List of whiteListIds:\n%1", cannotDisable: "❌ | Whitelist mode is permanently enabled and cannot be turned off.", notAdmin: "⛔ | শুধুমাত্র Bot Owner/Admin এই কমান্ড ব্যবহার করতে পারবে।" } }, // বট স্টার্ট হওয়ার সাথে সাথে এই ফাংশনটা একবার রান হয় — whitelist অটো ON করে দেয় onLoad: function () { try { const { writeFileSync } = require("fs-extra"); if (!config.whiteListMode) config.whiteListMode = { enable: true, whiteListIds: [] }; if (config.whiteListMode.enable !== true) { config.whiteListMode.enable = true; writeFileSync(global.client.dirConfig, JSON.stringify(config, null, 2)); console.log("✅ [wl.js] Whitelist mode auto-enabled on bot start."); } } catch (error) { console.log("❌ [wl.js] onLoad error:", error); } }, onStart: async function ({ message, args, usersData, event, getLang, api }) { const { writeFileSync } = require("fs-extra"); // ==== ম্যানুয়াল ADMIN চেক — GoatBot এর role সিস্টেমের উপর নির্ভর না করে সরাসরি adminBot লিস্ট চেক ==== const adminBotList = (config.adminBot || []).map(id => String(id)); const senderID = String(event.senderID); if (!adminBotList.includes(senderID)) { return message.reply(getLang("notAdmin")); } // ==== END ADMIN চেক ==== // প্রতিবার কমান্ড রান হওয়ার আগেও নিশ্চিত করা হচ্ছে যে whitelist mode বন্ধ নেই if (config.whiteListMode.enable !== true) { config.whiteListMode.enable = true; writeFileSync(global.client.dirConfig, JSON.stringify(config, null, 2)); } switch (args[0]) { case "add": case "-a": { if (args[1]) { let uids = []; if (Object.keys(event.mentions).length > 0) uids = Object.keys(event.mentions); else if (event.messageReply) uids.push(event.messageReply.senderID); else uids = args.filter(arg => !isNaN(arg)); const notWhiteListIds = []; const whiteListIds = []; for (const uid of uids) { if (config.whiteListMode.whiteListIds.includes(uid)) whiteListIds.push(uid); else notWhiteListIds.push(uid); } config.whiteListMode.whiteListIds.push(...notWhiteListIds); const getNames = await Promise.all(notWhiteListIds.map(uid => usersData.getName(uid).then(name => ({ uid, name })))); writeFileSync(global.client.dirConfig, JSON.stringify(config, null, 2)); return message.reply( (notWhiteListIds.length > 0 ? getLang("added", notWhiteListIds.length, getNames.map(({ uid, name }) => `• ${name} (${uid})`).join("\n")) : "") + (whiteListIds.length > 0 ? getLang("alreadyWhiteList", whiteListIds.length, whiteListIds.map(uid => `• ${uid}`).join("\n")) : "") ); } else return message.reply(getLang("missingIdAdd")); } case "remove": case "-r": { if (args[1]) { let uids = []; if (Object.keys(event.mentions).length > 0) uids = Object.keys(event.mentions); else uids = args.filter(arg => !isNaN(arg)); const notWhiteListIds = []; const whiteListIds = []; for (const uid of uids) { if (config.whiteListMode.whiteListIds.includes(uid)) whiteListIds.push(uid); else notWhiteListIds.push(uid); } for (const uid of whiteListIds) config.whiteListMode.whiteListIds.splice(config.whiteListMode.whiteListIds.indexOf(uid), 1); const getNames = await Promise.all(whiteListIds.map(uid => usersData.getName(uid).then(name => ({ uid, name })))); writeFileSync(global.client.dirConfig, JSON.stringify(config, null, 2)); return message.reply( (whiteListIds.length > 0 ? getLang("removed", whiteListIds.length, getNames.map(({ uid, name }) => `• ${name} (${uid})`).join("\n")) : "") + (notWhiteListIds.length > 0 ? getLang("notWhiteList", notWhiteListIds.length, notWhiteListIds.map(uid => `• ${uid}`).join("\n")) : "") ); } else return message.reply(getLang("missingIdRemove")); } case "list": case "-l": { const getNames = await Promise.all(config.whiteListMode.whiteListIds.map(uid => usersData.getName(uid).then(name => ({ uid, name })))); return message.reply(getLang("listWhiteList", getNames.map(({ uid, name }) => `• ${name} (${uid})`).join("\n"))); } case "on": { config.whiteListMode.enable = true; writeFileSync(global.client.dirConfig, JSON.stringify(config, null, 2)); return message.reply("✅ Whitelist mode is ON (and cannot be turned off)."); } case "off": { return message.reply(getLang("cannotDisable")); } default: return message.reply("❌ Invalid command. Use: add, remove, list, on"); } } };