goat
command
hug3
๐ค Create a cute hug image between you and your tagged partner!
0
views
0
likes
0
installs
raw source
const fs = require("fs-extra");
const path = require("path");
const axios = require("axios");
module.exports = {
config: {
name: "hug3",
version: "1.1",
author: "Saimx69x update by xalman",
countDown: 5,
role: 0,
description: "๐ค Create a cute hug image between you and your tagged partner!",
category: "love",
guide: {
en: "{pn} @tag or reply โ Generate hug image ๐ค"
}
},
langs: {
en: {
noTag: "Please tag someone or reply to their message to use this command ๐ค",
fail: "โ | Couldn't generate hug image, Please try again later."
}
},
onStart: async function ({ event, message, usersData, getLang }) {
const uid1 = event.senderID;
let uid2 = Object.keys(event.mentions || {})[0];
if (!uid2 && event.messageReply?.senderID) {
uid2 = event.messageReply.senderID;
}
if (!uid2) return message.reply(getLang("noTag"));
try {
const [name1, name2] = await Promise.all([
usersData.getName(uid1).catch(() => "Unknown"),
usersData.getName(uid2).catch(() => "Unknown")
]);
const width = 512;
const height = 512;
const accessToken = "350685531728|62f8ce9f74b12f84c123cc23437a4a32";
const avatar1 = `https://graph.facebook.com/${uid1}/picture?width=${width}&height=${height}&access_token=${accessToken}`;
const avatar2 = `https://graph.facebook.com/${uid2}/picture?width=${width}&height=${height}&access_token=${accessToken}`;
const GITHUB_RAW = "https://raw.githubusercontent.com/Saim-x69x/sakura/main/ApiUrl.json";
const rawRes = await axios.get(GITHUB_RAW);
const apiBase = rawRes.data.apiv1;
const apiURL = `${apiBase}/api/hug?boy=${encodeURIComponent(avatar1)}&girl=${encodeURIComponent(avatar2)}`;
const response = await axios.get(apiURL, { responseType: "arraybuffer" });
const saveDir = path.join(__dirname, "tmp");
await fs.ensureDir(saveDir);
const imgPath = path.join(saveDir, `${uid1}_${uid2}_hug.jpg`);
await fs.writeFile(imgPath, response.data);
const text = `๐ค ${name1} just hugged ${name2}! โค๏ธ`;
await message.reply({
body: text,
attachment: fs.createReadStream(imgPath)
});
setTimeout(() => {
if (fs.existsSync(imgPath)) fs.unlinkSync(imgPath);
}, 5000);
} catch (err) {
console.error("โ Hug command error:", err);
return message.reply(getLang("fail"));
}
}
};