// code from goatstore // api: https://store.agi.bd module.exports = { config: { name: "pending", version: "1.0", author: "—͞𝐏ʀɪᴍᴇ́", countDown: 5, role: 2, shortDescription: "Show pending groups", longDescription: "Show pending groups and approve/delete by reply", category: "admin", guide: "{pn} -> reply or delete " }, onStart: async function ({ api, event }) { const { threadID } = event; global.GoatBot.pendingCache = global.GoatBot.pendingCache || {}; const list = await api.getThreadList(100, null, ["PENDING"]); const groups = list.filter(g => g.isGroup); if (groups.length === 0) { return api.sendMessage("No pending groups found", threadID); } let msg = `Total Pending: ${groups.length}\n\n`; groups.forEach((g, i) => { msg += `${i + 1}. ${g.name || "Unnamed"}\nID: ${g.threadID}\n\n`; }); msg += `Reply this message:\n- to Approve\n- delete to Delete`; api.sendMessage(msg, threadID, (err, info) => { global.GoatBot.pendingCache[info.messageID] = groups; }); }, onChat: async function ({ api, event }) { const { threadID, messageID, body, messageReply } = event; if (!messageReply ||!body) return; global.GoatBot.pendingCache = global.GoatBot.pendingCache || {}; const cache = global.GoatBot.pendingCache[messageReply.messageID]; if (!cache) return; const args = body.trim().split(/\s+/); let action = "approve"; let serials = []; if (args[0].toLowerCase() === "delete" || args[0].toLowerCase() === "del" || args[0].toLowerCase() === "remove") { action = "delete"; serials = args.slice(1).map(n => parseInt(n)).filter(n =>!isNaN(n)); } else { serials = args.map(n => parseInt(n)).filter(n =>!isNaN(n)); } if (serials.length === 0) return; for (let num of serials) { const group = cache[num - 1]; if (!group) { await api.sendMessage(`Serial ${num} not found`, threadID, messageID); continue; } if (action === "approve") { try { await api.handleMessageRequest(group.threadID, true); await api.sendMessage(`Approved: ${num}. ${group.name || "Unnamed"}`, threadID, messageID); } catch { await api.sendMessage(`Failed to approve ${num}`, threadID, messageID); } } if (action === "delete") { try { await api.handleMessageRequest(group.threadID, false); await api.sendMessage(`Deleted: ${num}. ${group.name || "Unnamed"}`, threadID, messageID); } catch { await api.sendMessage(`Failed to delete ${num}`, threadID, messageID); } } } } };