← back to browse
goat command

spy

Get user information and a styled banner

0
views
0
likes
0
installs

Aliases: whoishe, whoisshe, whoami, atake

raw source
const axios = require("axios");

const baseApiUrl = async () => {
 const base = await axios.get(`https://raw.githubusercontent.com/Blankid018/D1PT0/main/baseApiUrl.json`);
 return base.data.api;
};

module.exports = {
 config: {
 name: "spy",
 aliases: ["whoishe", "whoisshe", "whoami", "atake"],
 version: "2.1",
 author: "Chitron Bhattacharjee",
 role: 0,
 countDown: 10,
 description: "Get user information and a styled banner",
 category: "information"
 },

 onStart: async function ({ event, message, usersData, api, args }) {
 const uidSelf = event.senderID;
 const uidMentioned = 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
 : uidMentioned || uidSelf;

 const userInfo = await api.getUserInfo(uid);
 const avatarUrl = await usersData.getAvatarUrl(uid);
 const user = userInfo[uid];

 const nickname = (await usersData.get(uid))?.nickName || user.alternateName || "๐™ฝ๐š˜๐š—๐šŽ";
 const username = user.vanity || "๐™ฝ๐š˜๐š—๐šŽ";
 const profileUrl = user.profileUrl || "๐™ฟ๐š›๐š’๐šŸ๐šŠ๐š๐šŽ";
 const birthday = user.isBirthday !== false ? user.isBirthday : "๐™ฟ๐š›๐š’๐šŸ๐šŠ๐š๐šŽ";
 const gender = user.gender === 1 ? "๐Ÿ‘ง Girl" : user.gender === 2 ? "๐Ÿ‘ฆ Boy" : "๐ŸŒ€ Undefined";
 const isFriend = user.isFriend ? "โœ… Yes" : "โŒ No";
 const position = user.type?.toUpperCase() || "Normal User";

 const allUser = await usersData.getAll();
 const userData = await usersData.get(uid);
 const money = userData.money || 0;
 const exp = userData.exp || 0;

 const rank = allUser.slice().sort((a, b) => b.exp - a.exp)
 .findIndex(u => u.userID === uid) + 1;

 const moneyRank = allUser.slice().sort((a, b) => b.money - a.money)
 .findIndex(u => u.userID === uid) + 1;

 // Baby teach system
 let babyTeach = 0;
 try {
 const res = await axios.get(`${await baseApiUrl()}/baby?list=all`);
 const babyList = res.data?.teacher?.teacherList || [];
 babyTeach = babyList.find(t => t[uid])?.[uid] || 0;
 } catch { }

 const info = `
โ•ญโ”€๐ŸŽ€ ๐—จ๐—ฆ๐—˜๐—ฅ ๐—œ๐—ก๐—™๐—ข ๐ŸŽ€โ”€โ•ฎ
๐Ÿ‘ค ๐—ก๐—ฎ๐—บ๐—ฒ: ${user.name}
๐Ÿ†” ๐—จ๐—œ๐——: ${uid}
โšง ๐—š๐—ฒ๐—ป๐—ฑ๐—ฒ๐—ฟ: ${gender}
๐Ÿงญ ๐—ฅ๐—ผ๐—น๐—ฒ: ${position}
๐Ÿ”— ๐—จ๐˜€๐—ฒ๐—ฟ๐—ป๐—ฎ๐—บ๐—ฒ: ${username}
๐ŸŒ ๐—ฃ๐—ฟ๐—ผ๐—ณ๐—ถ๐—น๐—ฒ: ${profileUrl}
๐ŸŽ‚ ๐—•๐—ถ๐—ฟ๐˜๐—ต๐—ฑ๐—ฎ๐˜†: ${birthday}
๐Ÿค ๐—™๐—ฟ๐—ถ๐—ฒ๐—ป๐—ฑ ๐—ช๐—ถ๐˜๐—ต ๐—•๐—ผ๐˜: ${isFriend}
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

โ•ญโ”€โ”€ ๐Ÿ“Š ๐—ฆ๐—ง๐—”๐—ง๐—ฆ ๐Ÿ“Š โ”€โ”€โ•ฎ
๐Ÿ’ฐ ๐— ๐—ผ๐—ป๐—ฒ๐˜†: $${formatMoney(money)}
๐Ÿ“ˆ ๐—ฅ๐—ฎ๐—ป๐—ธ: #${rank}/${allUser.length}
๐Ÿ’ธ ๐— ๐—ผ๐—ป๐—ฒ๐˜† ๐—ฅ๐—ฎ๐—ป๐—ธ: #${moneyRank}/${allUser.length}
๐Ÿ‘ถ ๐—•๐—ฎ๐—ฏ๐˜† ๐—ง๐—ฒ๐—ฎ๐—ฐ๐—ต: ${babyTeach}
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

โœจ ๐˜‰๐˜ฐ๐˜ต ๐˜ฃ๐˜บ: ๐˜Š๐˜ฉ๐˜ช๐˜ต๐˜ณ๐˜ฐ๐˜ฏ ๐˜‰๐˜ฉ๐˜ข๐˜ต๐˜ต๐˜ข๐˜ค๐˜ฉ๐˜ข๐˜ณ๐˜ซ๐˜ฆ๐˜ฆ โœจ`.trim();

 // Generate banner via Popcat API
 const bannerUrl = `https://api.popcat.xyz/welcomecard` +
 `?username=${encodeURIComponent(user.name)}` +
 `&discriminator=${uid.slice(-4)}` +
 `&avatar=${encodeURIComponent(avatarUrl)}` +
 `&background=${encodeURIComponent("https://shipu.c0m.in/banner.png")}` +
 `&color=${randomColor()}` +
 `&text1=${encodeURIComponent(user.name)}` +
 `&text2=${encodeURIComponent("API Ownerโ€”")}` +
 `&text3=${encodeURIComponent("Chitron Bhattacharjee")}`;

 return message.reply({
 body: info,
 attachment: await global.utils.getStreamFromURL(bannerUrl)
 });
 }
};

// Format large numbers with suffix
function formatMoney(num) {
 const units = ["", "K", "M", "B", "T", "Q", "Qi", "Sx", "Sp", "Oc", "N"];
 let unit = 0;
 while (num >= 1000 && ++unit < units.length) num /= 1000;
 return num.toFixed(1).replace(/\.0$/, "") + units[unit];
}

// Random color for banner
function randomColor() {
 const colors = ["red", "blue", "purple", "green", "yellow", "pink", "orange", "aqua"];
 return colors[Math.floor(Math.random() * colors.length)];
}

View raw file