module.exports = { config: { name: "profile", aliases: ["pfp", "pp", "dp"], version: "0.0.8", role: 0, author: "Arafat", description: "Get users profile photo", category: "information", countDown: 10, }, onStart: async function ({ event, message, usersData, api, args, threadsData }) { try { const uid1 = event.senderID; const uid2 = Object.keys(event.mentions)[0]; let uid; if (args[0]) { if (/^\d+$/.test(args[0])) { uid = args[0]; } else { const match = args[0].match(/profile\.php\?id=(\d+)/); if (match) uid = match[1]; } } if (!uid) { uid = event.type === "message_reply" ? event.messageReply.senderID : uid2 || uid1; } let userInfo; try { userInfo = await api.getUserInfo(uid); } catch (e) { return message.reply("āŒ | Failed to fetch user profile picture."); } const uInfo = userInfo[uid] || {}; // FIX 1: Try usersData first, then fall back to userInfo's own avatar fields let avatarUrl = null; try { avatarUrl = await usersData.getAvatarUrl(uid); } catch (e) { // FIX 2: Fall back to the profileUrl / thumbSrc from userInfo avatarUrl = uInfo.profileUrl || uInfo.thumbSrc || null; } function toSerifBold(text) { const map = { A:"š€",B:"š",C:"š‚",D:"šƒ",E:"š„",F:"š…",G:"š†",H:"š‡",I:"šˆ",J:"š‰", K:"šŠ",L:"š‹",M:"šŒ",N:"š",O:"šŽ",P:"š",Q:"š",R:"š‘",S:"š’",T:"š“", U:"š”",V:"š•",W:"š–",X:"š—",Y:"š˜",Z:"š™", a:"šš",b:"š›",c:"šœ",d:"š",e:"šž",f:"šŸ",g:"š ",h:"š”",i:"š¢",j:"š£", k:"š¤",l:"š„",m:"š¦",n:"š§",o:"šØ",p:"š©",q:"šŖ",r:"š«",s:"š¬",t:"š­", u:"š®",v:"šÆ",w:"š°",x:"š±",y:"š²",z:"š³", 0:"šŸŽ",1:"šŸ",2:"šŸ",3:"šŸ‘",4:"šŸ’",5:"šŸ“",6:"šŸ”",7:"šŸ•",8:"šŸ–",9:"šŸ—" }; return String(text).split("").map(c => map[c] || c).join(""); } let isAdmin = "N/A"; if (event.threadID) { try { const threadInfo = await threadsData.get(event.threadID); if (threadInfo?.adminIDs) { isAdmin = threadInfo.adminIDs.includes(uid) ? "āœ… š˜šžš¬" : "āŽ ššØ"; } } catch (e) {} } const userName = toSerifBold(uInfo.name || "Unknown"); const userInformation = `>šŸŽ€ ${userName} šššš›š², š‡šžš«šž'š¬ š²šØš®š« š©š«šØšŸš¢š„šž 😘`; // FIX 3: Try to stream the avatar, log errors, and inform user if unavailable let attachments = []; if (avatarUrl) { try { const stream = await global.utils.getStreamFromURL(avatarUrl); if (stream) { attachments.push(stream); } else { console.warn(`[profile] getStreamFromURL returned falsy for uid ${uid}`); } } catch (e) { console.error(`[profile] Failed to stream avatar for uid ${uid}:`, e); } } // FIX 4: Notify user if avatar could not be loaded instead of silently omitting it const body = attachments.length === 0 ? `${userInformation}\n\nāš ļø | Could not load profile picture.` : userInformation; await message.reply({ body, attachment: attachments.length > 0 ? attachments : undefined }); } catch (error) { console.error("Profile command error:", error); return message.reply("āŒ | An error occurred."); } }, };