// code from goatstore // api: https://store.agi.bd async function formatNick(nick, uid, usersData) { try { if (nick.includes("{userName}")) nick = nick.replace(/{userName}/gi, await usersData.getName(uid)); if (nick.includes("{userID}")) nick = nick.replace(/{userID}/gi, uid); } catch {} return nick; } function escapeRegex(str) { return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); } module.exports = { config: { name: "setname", version: "4.1", author: "๐Œ๐š๐‘๐ฎ๐…", role: 0, category: "group", guide: "{pn} | reply + {pn} | {pn} @mention " }, onStart: async function ({ api, event, args, message, usersData }) { let nick = args.join(" ").trim(); if (!nick) return message.reply("โŒ ๐๐ข๐œ๐ค๐ง๐š๐ฆ๐ž ๐๐š๐จ โœจ"); let uids = []; const mentions = Object.keys(event.mentions); if (event.messageReply) { uids = [event.messageReply.senderID]; } else if (mentions.length > 0) { uids = mentions; const names = Object.values(event.mentions).map(escapeRegex).join("|"); if (names) nick = nick.replace(new RegExp(names, "g"), "").trim(); } else { uids = [event.senderID]; } if (!nick) return message.reply("โŒ ๐๐š๐ฆ๐ž ๐ž๐ฆ๐ฉ๐ญ๐ฒ!"); for (const uid of uids) { const finalNick = await formatNick(nick, uid, usersData); await api.changeNickname(finalNick, event.threadID, uid); } return message.reply(`โœ… ๐๐ข๐œ๐ค๐ง๐š๐ฆ๐ž ๐‚๐ก๐š๐ง๐ ๐ž๐ ๐Ÿฅ‚\nยป ${nick}`); } };