goat
command
bou
oilo bou / bow
0
views
0
likes
0
installs
Aliases: bow
raw source
const axios = require("axios");
const fs = require("fs-extra");
const path = require("path");
module.exports = {
config: {
name: "bou",
aliases: ["bow"],
version: "0.0.8",
author: "Azadx69x",
countDown: 5,
role: 0,
shortDescription: { en: "oilo bou / bow" },
longDescription: { en: "Random Bow from group" },
category: "fun",
guide: "{pn}"
},
onStart: async ({ api, event, usersData }) => {
const { threadID, messageID } = event;
try {
const info = await api.getThreadInfo(threadID);
const femaleOnly = info.userInfo.filter(user => {
const g = user.gender;
if (!g) return false;
if (typeof g === "number") return g % 2 === 1;
if (typeof g === "string") return g.trim().charAt(0).toLowerCase() === "f";
if (g && g.isFemale === true) return true;
return false;
});
if (!femaleOnly.length) {
return api.sendMessage("๐ ๐๐จ ๐๐๐ฆ๐๐ฅ๐ ๐ฎ๐ฌ๐๐ซ๐ฌ ๐๐จ๐ฎ๐ง๐ ๐ข๐ง ๐ญ๐ก๐ข๐ฌ ๐ ๐ซ๐จ๐ฎ๐ฉ!", threadID, messageID);
}
const pick = femaleOnly[Math.floor(Math.random() * femaleOnly.length)];
const uid = pick.id;
let avatar = await usersData.getAvatarUrl(uid);
if (!avatar) avatar = `https://graph.facebook.com/${uid}/picture?width=600`;
const folder = path.join(__dirname, "cache");
await fs.ensureDir(folder);
const imgPath = path.join(folder, `${uid}.jpg`);
const img = await axios.get(avatar, { responseType: "arraybuffer" });
await fs.writeFile(imgPath, img.data);
const infoUser = await api.getUserInfo(uid);
const name = infoUser[uid]?.name || "๐๐ง๐ค๐ง๐จ๐ฐ๐ง";
const link = `https://facebook.com/${uid}`;
const msg =
`๐ ๐๐๐๐ ๐๐๐
๐ ๐๐ ๐๐๐๐! ๐
๐ ๐๐๐ฆ๐: ${name}
๐ ๐๐๐: ${uid}
๐ ๐๐ซ๐จ๐๐ข๐ฅ๐: ${link}
๐ ๐๐ซ๐๐๐ญ ๐ก๐๐ซ ๐ฐ๐๐ฅ๐ฅ! ๐`;
api.sendMessage(
{ body: msg, attachment: fs.createReadStream(imgPath) },
threadID,
() => fs.unlinkSync(imgPath)
);
} catch (err) {
api.sendMessage("๐ ๐๐ซ๐ซ๐จ๐ซ ๐จ๐๐๐ฎ๐ซ๐ซ๐๐!", threadID, messageID);
}
}
};