// code from goatstore // api: https://store.agi.bd "use strict"; module.exports = { config: { name: "pending", version: "1.3.1", author: "MaRuF", aliases: [], role: 2, shortDescription: "Manage bot's waiting groups", longDescription: "Approve or cancel pending groups", category: "owner", countDown: 5 }, _getText(key,...args) { const texts = { invaildNumber: "🄺 Oops! %1 is not a valid number", cancelSuccess: "šŸ—‘ļø Deleted %1 group(s) successfully", approveSuccess: "🌸 Approved %1 group(s) successfully", cantGetPendingList: "šŸ’” Can't get the pending list", returnListClean: "šŸ“­ No pending groups found" }; const text = texts[key] || key; return args.length? text.replace("%1", args[0]) : text; }, onStart: async function ({ api, event }) { const { threadID, messageID, senderID } = event; let pendingList = []; try { const other = await api.getThreadList(100, null, ["OTHER"]); const pending = await api.getThreadList(100, null, ["PENDING"]); pendingList = [...other,...pending].filter( g => g.isGroup && g.isSubscribed // tomar original filter e rakhlam ); } catch { return api.sendMessage( this._getText("cantGetPendingList"), threadID, messageID ); } if (!pendingList.length) return api.sendMessage( this._getText("returnListClean"), threadID, messageID ); const prefix = global.GoatBot?.config?.prefix || "!"; let msg = `✨ šš„ššƒšˆšš† š†š‘šŽš”šš’ : ${pendingList.length} ✨\n`; msg += `━━━━━━━━━━━━━━\n`; pendingList.forEach((g, i) => { msg += `šŸ”¹ ${i + 1}. šššš¦šž : ${g.name || "š”š§ššš¦šžš"}\n`; msg += `šŸ†” šˆšƒ : ${g.threadID}\n`; msg += `──────────────\n`; }); msg += `\nšŸ’Œ š‡šŽš– š“šŽ š”š’š„ :\n`; msg += `āœ… š€š©š«šØšÆšž : ${prefix}š©šžš§šš¢š§š  1 2\n`; msg += `āŒ š‚ššš§šœšžš„ : ${prefix}š©šžš§šš¢š§š  šœ 1 2`; return api.sendMessage(msg, threadID, (err, info) => { global.GoatBot.onReply.set(info.messageID, { commandName: this.config.name, author: senderID, pending: pendingList }); }, messageID); }, onReply: async function ({ event, Reply, api }) { const { author, pending } = Reply; if (String(event.senderID)!== String(author)) return; const input = event.body.trim().toLowerCase().split(/\s+/); const botID = api.getCurrentUserID(); const prefix = global.GoatBot?.config?.prefix || "!"; let count = 0; if (input[0] === "c" || input[0] === "cancel") { for (let i = 1; i < input.length; i++) { const idx = parseInt(input[i]); if (isNaN(idx) || idx <= 0 || idx > pending.length) return api.sendMessage( this._getText("invaildNumber", input[i]), event.threadID ); await api.removeUserFromGroup(botID, pending[idx - 1].threadID); count++; } return api.sendMessage( this._getText("cancelSuccess", count), event.threadID ); } for (const v of input) { const idx = parseInt(v); if (isNaN(idx) || idx <= 0 || idx > pending.length) return api.sendMessage( this._getText("invaildNumber", v), event.threadID ); const tID = pending[idx - 1].threadID; await api.sendMessage( `✨ š†š‘šŽš”š š€š‚š“šˆš•š€š“š„šƒ ✨ šŸ’« š‡šžš„šØ š„šÆšžš«š²šØš§šž šŸ‘‹ šŸ¤– šˆ'š¦ ššØš° šŽš§š„š¢š§šž āœ… āš™ļø šš«šžšŸš¢š± : ${prefix} šŸ“œ š‡šžš„š© : ${prefix}š”šžš„š© šŸ’Ž š“š”ššš§š¤š¬ š…šØš« š€šš¢š§š  šŒšž šŸ’Ž`, tID); const nickNameBot = global.GoatBot?.config?.nickNameBot; if (nickNameBot) await api.changeNickname(nickNameBot, tID, botID); count++; } return api.sendMessage( this._getText("approveSuccess", count), event.threadID ); } };