// code from goatstore // api: https://store.agi.bd module.exports = { config: { name: "botnick", aliases: ["bn", "setbotnick"], version: "1.3", author: "Grok", countDown: 10, role: 2, description: { en: "Change bot nickname in all groups" }, category: "admin", guide: { en: "{pn} " } }, onStart: async function ({ api, args, message, threadsData }) { const newNick = args.join(" ").trim(); if (!newNick) { return message.reply("⚠️ Nickname den!\nExample: botnick ❤️ GoatBot"); } const allThreads = await threadsData.getAll(); const groupThreads = allThreads.filter(t => t.isGroup && t.members && t.members.find(m => m.userID == api.getCurrentUserID() && m.inGroup) ); if (groupThreads.length === 0) { return message.reply("❌ Kon o group pawa jayni."); } await message.reply(`⏳ Nickname "${newNick}" set hocche ${groupThreads.length} ta group e...\nPlease wait...`); let success = 0; let failed = 0; for (const thread of groupThreads) { try { await api.changeNickname(newNick, thread.threadID, api.getCurrentUserID()); success++; await new Promise(resolve => setTimeout(resolve, 600)); } catch (err) { failed++; } } return message.reply( `✅ Done!\n` + `📌 New Nick: ${newNick}\n` + `✅ Success: ${success} groups\n` + `❌ Failed: ${failed} groups` ); } };