// code from goatstore // api: https://store.agi.bd const { config } = global.GoatBot; const { writeFileSync } = require("fs-extra"); const moment = require("moment-timezone"); const OWNER = [ "61559237171744", "" ]; module.exports = { config: { name: "wl", version: "2.0", author: "MR_FARHAN + SIYAM EDIT", countDown: 5, role: 2, longDescription: { en: "Manage whiteListIds" }, category: "owner", guide: { en: "{pn} add \n" + "{pn} remove \n" + "{pn} list\n" + "{pn} on / off" } }, langs: { en: { added: "โœ… Added:\n%1", removed: "โœ… Removed:\n%1", listAdmin: "๐Ÿ‘‘ WhiteList Users:\n%1", missingIdAdd: "โš ๏ธ Give ID or tag", missingIdRemove: "โš ๏ธ Give ID or tag" } }, onStart: async function ({ message, args, usersData, event, getLang }) { const senderID = event.senderID; // ๐Ÿ‘‘ OWNER + BOT ADMIN ACCESS CHECK const isOwner = OWNER.includes(senderID); const isAdmin = config.adminBot.includes(senderID); // (ONLY PROTECT MAIN ACTIONS) function hasAccess() { return isOwner || isAdmin; } switch (args[0]) { // ================= ADD ================= case "add": case "-a": { if (!hasAccess()) return message.reply("โŒ Access Denied"); if (!args[1]) return message.reply(getLang("missingIdAdd")); 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 added = []; for (const uid of uids) { if (!config.whiteListMode.whiteListIds.includes(uid)) { config.whiteListMode.whiteListIds.push(uid); added.push(uid); } } writeFileSync(global.client.dirConfig, JSON.stringify(config, null, 2)); const names = await Promise.all( added.map(uid => usersData.getName(uid).then(name => `โ€ข ${name} (${uid})`)) ); return message.reply(getLang("added", names.join("\n"))); } // ================= REMOVE ================= case "remove": case "-r": { if (!hasAccess()) return message.reply("โŒ Access Denied"); if (!args[1]) return message.reply(getLang("missingIdRemove")); let uids = []; if (Object.keys(event.mentions).length > 0) uids = Object.keys(event.mentions); else uids = args.filter(arg => !isNaN(arg)); const removed = []; for (const uid of uids) { if (config.whiteListMode.whiteListIds.includes(uid)) { config.whiteListMode.whiteListIds.splice( config.whiteListMode.whiteListIds.indexOf(uid), 1 ); removed.push(uid); } } writeFileSync(global.client.dirConfig, JSON.stringify(config, null, 2)); const names = await Promise.all( removed.map(uid => usersData.getName(uid).then(name => `โ€ข ${name} (${uid})`)) ); return message.reply(getLang("removed", names.join("\n"))); } // ================= LIST ================= case "list": case "-l": { if (!hasAccess()) return message.reply("โŒ Access Denied"); const names = await Promise.all( config.whiteListMode.whiteListIds.map(uid => usersData.getName(uid).then(name => `โ€ข ${name} (${uid})`) ) ); return message.reply(getLang("listAdmin", names.join("\n"))); } // ================= ON ================= case "on": { if (!hasAccess()) return message.reply("โŒ Access Denied"); config.whiteListMode.enable = true; writeFileSync(global.client.dirConfig, JSON.stringify(config, null, 2)); const time = moment().tz("Asia/Dhaka").format("hh:mm A"); const date = moment().tz("Asia/Dhaka").format("DD MMMM YYYY"); return message.reply(` ๐Ÿ‘‘ ๐‘๐€๐˜๐‡๐€๐-๐’๐€๐๐๐ˆ๐‘ ๐Ÿ‘‘ ๐† แ๐–๐‡๐ˆ๐“๐„ ๐‹๐ˆ๐’๐“ ๐Œ๐Ž๐ƒ๐„ ๐„๐๐€๐๐‹๐„๐ƒ ๐Ÿ” ๐† แ๐€๐‚๐‚๐„๐’๐’ : ๐† แ๐Ÿธเฆเฆ–เฆจ เฆถเงเฆงเง เฆ†เฆฎเฆพเฆฐ เฆฌเฆธ เฆฐเฆพเฆฏเฆผเฆนเฆพเฆจ,๐Ÿชฌ ๐† แเฆฌเฆŸ เฆฌเงเฆฏเฆฌเฆนเฆพเฆฐ เฆ•เฆฐเฆคเง‡ เฆชเฆพเฆฐเฆฌเง‡ ๐Ÿ‘‘ ๐Ÿ“… ๐† แ๐ƒ๐š๐ญ๐ž : ${date} โฐ ๐† แ๐“๐ข๐ฆ๐ž : ${time} ๐Ÿ‘‘ ๐† แ๐๐ˆ๐‰๐‡๐”๐Œ ๐‚๐‡๐€๐“ ๐๐Ž๐“ ๐Ÿ‘‘ `); } // ================= OFF ================= case "off": { if (!hasAccess()) return message.reply("โŒ Access Denied"); config.whiteListMode.enable = false; writeFileSync(global.client.dirConfig, JSON.stringify(config, null, 2)); const time = moment().tz("Asia/Dhaka").format("hh:mm A"); const date = moment().tz("Asia/Dhaka").format("DD MMMM YYYY"); return message.reply(` ๐Ÿ‘‘ ๐‘๐€๐˜๐‡๐€๐-๐’๐€๐๐๐ˆ๐‘ ๐Ÿ‘‘ ๐† แ๐–๐‡๐ˆ๐“๐„ ๐‹๐ˆ๐’๐“ ๐Œ๐Ž๐ƒ๐„ ๐ƒ๐ˆ๐’๐€๐๐‹๐„๐ƒ ๐ŸŒ ๐† แ๐€๐‚๐‚๐„๐’๐’ : ๐† แเฆเฆ–เฆจ เฆธเฆฌเฆพเฆ‡ เฆฌเฆŸ เฆฌเงเฆฏเฆฌเฆนเฆพเฆฐ๐Ÿชฌ ๐† แเฆ•เฆฐเฆคเง‡ เฆชเฆพเฆฐเฆฌเง‡ ๐ŸŽ‰ ๐Ÿ“… ๐† แ๐ƒ๐š๐ญ๐ž : ${date} โฐ ๐† แ๐“๐ข๐ฆ๐ž : ${time} ๐Ÿ‘‘ ๐† แ๐๐ˆ๐‰๐‡๐”๐Œ ๐‚๐‡๐€๐“ ๐๐Ž๐“ ๐Ÿ‘‘ `); } default: return message.SyntaxError(); } } };