← back to browse
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"));
    }
  }
};

View raw file