// code from goatstore // api: https://store.agi.bd const { config } = global.GoatBot; const { writeFileSync } = require("fs-extra"); module.exports = { config: { name: "whitelistthread", aliases: ["wlt", "wt"], version: "1.6", author: "badhon-00 | NoobDevs | Fixed by Md Hamim", countDown: 5, role: 2, description: { en: "Add, remove, edit whiteListThreadIds role" }, category: "owner", guide: { en: ' {pn} [add | -a | +] [...]: Add whiteListThreadIds role for the current thread or specified thread IDs' + '\n {pn} [remove | -r | -] [...]: Remove whiteListThreadIds role from the current thread or specified thread IDs' + '\n {pn} [list | -l]: List all whiteListThreadIds' + '\n {pn} [mode | -m] : Turn on/off whiteListThreadIds mode' + '\n {pn} [mode | -m] noti : Turn on/off notification for non-whiteListThreadIds' } }, langs: { en: { added: `\nβ•­β”€βœ¦βœ… | π™°πšπšπšŽπš %1 πšπš‘πš›πšŽπšŠπš/𝚜\n%2`, alreadyWLT: `β•­βœ¦βš οΈ | π™°πš•πš›πšŽπšŠπšπš’ 𝚊𝚍𝚍𝚎𝚍 %1 πšπš‘πš›πšŽπšŠπšπšœ\n%2\n`, missingTIDAdd: "⚠️ | π™Ώπš•πšŽπšŠπšœπšŽ πšŽπš—πšπšŽπš› πšƒπ™Έπ™³ 𝚝𝚘 𝚊𝚍𝚍 πš πš‘πš’πšπšŽπ™»πš’πšœπšπšƒπš‘πš›πšŽπšŠπš πš›πš˜πš•πšŽ", removed: `\nβ•­βœ¦βœ… | πšπšŽπš–πš˜πšŸπšŽπš %1 πšπš‘πš›πšŽπšŠπš/𝚜\n%2`, notAdded: `β•­βœ¦βŽ | π™³πš’πšπš—'𝚝 𝚊𝚍𝚍𝚎𝚍 %1 πšπš‘πš›πšŽπšŠπš/𝚜\n%2\n`, missingTIDRemove: "⚠️ | π™Ώπš•πšŽπšŠπšœπšŽ πšŽπš—πšπšŽπš› πšƒπ™Έπ™³ 𝚝𝚘 πš›πšŽπš–πš˜πšŸπšŽ πš πš‘πš’πšπšŽπ™»πš’πšœπšπšƒπš‘πš›πšŽπšŠπš πš›πš˜πš•πšŽ", listWLTs: `β•­βœ¦βœ¨ | π™»πš’πšœπš 𝚘𝚏 πšƒπš‘πš›πšŽπšŠπšπ™Έπšπšœ\n%1\nβ•°β€£ `, turnedOn: "βœ… | πšƒπšžπš›πš—πšŽπš πš˜πš— πšπš‘πšŽ πš–πš˜πšπšŽ πš˜πš—πš•πš’ πš πš‘πš’πšπšŽπ™»πš’πšœπšπšƒπš‘πš›πšŽπšŠπšπ™Έπšπšœ πšŒπšŠπš— 𝚞𝚜𝚎 πš‹πš˜πš", turnedOff: "❎ | πšƒπšžπš›πš—πšŽπš 𝚘𝚏𝚏 πšπš‘πšŽ πš–πš˜πšπšŽ πš˜πš—πš•πš’ πš πš‘πš’πšπšŽπ™»πš’πšœπšπšƒπš‘πš›πšŽπšŠπšπ™Έπšπšœ πšŒπšŠπš— 𝚞𝚜𝚎 πš‹πš˜πš", turnedOnNoti: "βœ… | πšƒπšžπš›πš—πšŽπš πš˜πš— πšπš‘πšŽ πš—πš˜πšπš’πšπš’πšŒπšŠπšπš’πš˜πš— πš πš‘πšŽπš— πšπš‘πš›πšŽπšŠπš πš’πšœ πš—πš˜πš πš πš‘πš’πšπšŽπ™»πš’πšœπšπšƒπš‘πš›πšŽπšŠπšπ™Έπšπšœ", turnedOffNoti: "❎ | πšƒπšžπš›πš—πšŽπš 𝚘𝚏𝚏 πšπš‘πšŽ πš—πš˜πšπš’πšπš’πšŒπšŠπšπš’πš˜πš— πš πš‘πšŽπš— πšπš‘πš›πšŽπšŠπš πš’πšœ πš—πš˜πš πš πš‘πš’πšπšŽπ™»πš’πšœπšπšƒπš‘πš›πšŽπšŠπšπ™Έπšπšœ", invalidSyntax: "❌ | Invalid syntax! Use {pn} for guide." } }, onStart: async function ({ message, args, event, getLang, api, threadsData }) { if (!config.whiteListModeThread) { config.whiteListModeThread = { enable: false, whiteListThreadIds: [], notification: false }; } const type = args[0] ? args[0].toLowerCase() : ""; switch (type) { case "add": case "-a": case "+": { let tids = args.slice(1).filter(arg => !isNaN(arg)); if (tids.length <= 0) { tids.push(event.threadID); } const notWLTIDs = []; const threadIDs = []; for (const tid of tids) { if (config.whiteListModeThread.whiteListThreadIds.includes(tid)) threadIDs.push(tid); else notWLTIDs.push(tid); } config.whiteListModeThread.whiteListThreadIds.push(...notWLTIDs); const getNames = await Promise.all(tids.map(async tid => { let threadName = "Not found"; try { const info = await threadsData.get(tid); threadName = info.threadName || (await api.getThreadInfo(tid)).threadName || "Group Thread"; } catch (e) { threadName = "Unknown/Private"; } return { tid, name: threadName }; })); writeFileSync(global.client.dirConfig, JSON.stringify(config, null, 2)); return message.reply( (notWLTIDs.length > 0 ? getLang("added", notWLTIDs.length, getNames.filter(({ tid }) => notWLTIDs.includes(tid)).map(({ tid, name }) => `β”œβ€£ πšƒπ™·πšπ™΄π™°π™³ 𝙽𝙰𝙼𝙴: ${name}\nβ•°β€£ πšƒπ™·πšπ™΄π™°π™³ 𝙸𝙳: ${tid}`).join("\n")) : "") + (threadIDs.length > 0 ? getLang("alreadyWLT", threadIDs.length, threadIDs.map(tid => `β•°β€£ πšƒπ™·πšπ™΄π™°π™³ 𝙸𝙳: ${tid}`).join("\n")) : "") ); } case "remove": case "rm": case "-r": case "-": { let tids = args.slice(1).filter(arg => !isNaN(arg)); if (tids.length <= 0) { tids.push(event.threadID); } const notWLTIDs = []; const threadIDs = []; for (const tid of tids) { if (config.whiteListModeThread.whiteListThreadIds.includes(tid)) threadIDs.push(tid); else notWLTIDs.push(tid); } for (const tid of threadIDs) { const index = config.whiteListModeThread.whiteListThreadIds.indexOf(tid); if (index > -1) config.whiteListModeThread.whiteListThreadIds.splice(index, 1); } const getNames = await Promise.all(threadIDs.map(async tid => { let threadName = "Not found"; try { const info = await threadsData.get(tid); threadName = info.threadName || (await api.getThreadInfo(tid)).threadName || "Group Thread"; } catch (e) { threadName = "Unknown/Private"; } return { tid, name: threadName }; })); writeFileSync(global.client.dirConfig, JSON.stringify(config, null, 2)); return message.reply( (threadIDs.length > 0 ? getLang("removed", threadIDs.length, getNames.map(({ tid, name }) => `β”œβ€£ πšƒπ™·πšπ™΄π™°π™³ 𝙽𝙰𝙼𝙴: ${name}\nβ•°β€£ πšƒπ™·πšπ™΄π™°π™³ 𝙸𝙳: ${tid}`).join("\n")) : "") + (notWLTIDs.length > 0 ? getLang("notAdded", notWLTIDs.length, notWLTIDs.map(tid => `β•°β€£ πšƒπ™·πšπ™΄π™°π™³ 𝙸𝙳: ${tid}`).join("\n")) : "") ); } case "list": case "-l": { if (config.whiteListModeThread.whiteListThreadIds.length === 0) { return message.reply("⚠️ | Whitelist list-e kono thread add kora nai."); } const getNames = await Promise.all(config.whiteListModeThread.whiteListThreadIds.map(async tid => { let threadName = "Unfetched"; try { const info = await threadsData.get(tid); threadName = info.threadName || "Group Thread"; } catch (e) { threadName = "Unknown"; } return { tid, name: threadName }; })); return message.reply(getLang("listWLTs", getNames.map(({ tid, name }) => `β”œβ€£ πšƒπ™·πšπ™΄π™°π™³ 𝙽𝙰𝙼𝙴: ${name}\nβ”œβ€£ πšƒπ™·πšπ™΄π™°π™³ 𝙸𝙳: ${tid}`).join("\n"))); } case "mode": case "m": case "-m": { if (args[1] === "noti") { if (args[2] === "on") { config.whiteListModeThread.notification = true; writeFileSync(global.client.dirConfig, JSON.stringify(config, null, 2)); return message.reply(getLang("turnedOnNoti")); } else if (args[2] === "off") { config.whiteListModeThread.notification = false; writeFileSync(global.client.dirConfig, JSON.stringify(config, null, 2)); return message.reply(getLang("turnedOffNoti")); } } else if (args[1] === "on") { config.whiteListModeThread.enable = true; writeFileSync(global.client.dirConfig, JSON.stringify(config, null, 2)); return message.reply(getLang("turnedOn")); } else if (args[1] === "off") { config.whiteListModeThread.enable = false; writeFileSync(global.client.dirConfig, JSON.stringify(config, null, 2)); return message.reply(getLang("turnedOff")); } return message.reply(getLang("invalidSyntax")); } default: { return message.reply(getLang("invalidSyntax")); } } } };