← back to browse
goat command

4k

Enhance or restore image quality using 4k AI.

0
views
0
likes
0
installs
raw source
const axios = require("axios");

const mahmud = async () => {
  const base = await axios.get("https://raw.githubusercontent.com/mahmudx7/HINATA/main/baseApiUrl.json");
  return base.data.mahmud;
};

/**
* @author MahMUD
* @author: do not delete it
*/

module.exports = {
  config: {
    name: "4k",
    version: "1.7",
    author: "๐“†ฉ๐‘…๐‘œ๐’ท๐’พ๐“ƒ๐“†ช ๐’œ๐“๐’พ",
    countDown: 10,
    role: 0,
    category: "AI",
    description: "Enhance or restore image quality using 4k AI.",
    guide: {
      en: "{pn} [url] or reply with image"
    }
  },

  onStart: async function ({ message, event, args }) {
    const startTime = Date.now();
    let imgUrl;

    if (event.messageReply?.attachments?.[0]?.type === "photo") {
      imgUrl = event.messageReply.attachments[0].url;
    }

    else if (args[0]) {
      imgUrl = args.join(" ");
    }

    if (!imgUrl) {
      return message.reply("Baby, Please reply to an image or provide an image URL");
    }
  
    const waitMsg = await message.reply("๐‹๐จ๐š๐๐ข๐ง๐  ๐Ÿ’๐ค ๐ข๐ฆ๐š๐ ๐ž...๐ฐ๐š๐ข๐ญ ๐›๐š๐›๐ฒ <๐Ÿ˜˜");
    message.reaction("๐Ÿ˜˜", event.messageID);

    try {
      
      const apiUrl = `${await mahmud()}/api/hd?imgUrl=${encodeURIComponent(imgUrl)}`;

      const res = await axios.get(apiUrl, { responseType: "stream" });
      if (waitMsg?.messageID) message.unsend(waitMsg.messageID);

      message.reaction("โœ…", event.messageID);

      const processTime = ((Date.now() - startTime) / 1000).toFixed(2);

      message.reply({
        body: `โœ… | ๐‡๐ž๐ซ๐ž'๐ฌ ๐ฒ๐จ๐ฎ๐ซ ๐Ÿ’๐ค ๐ข๐ฆ๐š๐ ๐ž ๐›๐š๐›๐ฒ`,
        attachment: res.data
      });

    } catch (error) {
  
      if (waitMsg?.messageID) message.unsend(waitMsg.messageID);

      message.reaction("โŽ", event.messageID);
      message.reply(`๐Ÿฅนerror baby, contact ๐“†ฉ๐‘…๐‘œ๐’ท๐’พ๐“ƒ๐“†ช ๐’œ๐“๐’พ.`);
    }
  }
};

View raw file