const axios = require("axios"); const fs = require("fs-extra"); const path = require("path"); module.exports = { config: { name: "4k", aliases: ["hd", "upscale", "enhance"], version: "2.5.0", author: "Arafat", countDown: 8, role: 0, shortDescription: { en: "High Quality Image Enhancer" }, longDescription: { en: "Convert your low-quality images into high-quality HD/4K images using AI." }, category: "image", guide: { en: "Reply to an image with {pn}" } }, onStart: async function ({ message, event, api }) { const { messageReply, messageID, threadID } = event; // 📸 āχāωāϜāĻžāϰ āĻ›āĻŦāĻŋāϤ⧇ āϰāĻŋāĻĒā§āϞāĻžāχ āĻ•āϰ⧇āϛ⧇ āĻ•āĻŋ āύāĻž āĻšā§‡āĻ• if (!messageReply || !messageReply.attachments || messageReply.attachments.length === 0) { return message.reply("❌ Please reply to an image to enhance it!"); } const attachment = messageReply.attachments[0]; if (attachment.type !== "photo") { return message.reply("❌ This is not a valid image. Please reply to a photo!"); } const imageUrl = attachment.url; // ⚡ āϰāĻŋ-āĻ…ā§āϝāĻžāĻ•āĻļāύ āĻāĻŦāĻ‚ āϞ⧋āĻĄāĻŋāĻ‚ āĻŽā§‡āϏ⧇āϜ (Goat-Bot āĻŽā§‡āĻĨāĻĄ āĻĢāĻŋāĻ•ā§āϏ) message.react("⚡"); const loadingMsg = await api.sendMessage("âŗ AI is enhancing your image... Please wait a moment.", threadID, messageID); try { // 🌐 āĻļāĻ•ā§āϤāĻŋāĻļāĻžāϞ⧀ āĻ“ āĻĻā§āϰ⧁āϤāĻ—āϤāĻŋāϰ āφāĻĒāĻĄā§‡āĻŸā§‡āĻĄ āĻāĻĒāĻŋāφāχ const apiRes = await axios.get(`https://samirxp.com{encodeURIComponent(imageUrl)}`); const resultUrl = apiRes.data.url || apiRes.data.imageUrl || apiRes.data.result; if (!resultUrl) { throw new Error("API failed to generate high-quality image URL."); } // đŸ“Ĩ āϞāĻžāχāĻ­ āχāωāφāϰāĻāϞ āĻĨ⧇āϕ⧇ āχāĻŽā§‡āϜ āĻ¸ā§āĻŸā§āϰāĻŋāĻŽ āϏāϰāĻžāϏāϰāĻŋ āĻŽā§‡āϏ⧇āĻžā§āϜāĻžāϰ⧇ āĻĒāĻžāĻ āĻžāύ⧋ āĻšāĻšā§āϛ⧇ const stream = await global.utils.getStreamFromURL(resultUrl); // āϞ⧋āĻĄāĻŋāĻ‚ āĻŽā§‡āϏ⧇āϜāϟāĻŋ āĻĄāĻŋāϞāĻŋāϟ āĻ•āϰ⧇ āĻĻ⧇āĻ“ā§ŸāĻž āĻšāĻšā§āϛ⧇ try { await api.unsendMessage(loadingMsg.messageID); } catch(e) {} message.react("✅"); return message.reply({ body: "✨ Here is your enhanced 4K Image!", attachment: stream }); } catch (err) { // āϝ⧇āϕ⧋āύ⧋ āĻāϰāϰ āĻšāϞ⧇ āϞ⧋āĻĄāĻŋāĻ‚ āĻŽā§‡āϏ⧇āϜ āϰāĻŋāĻŽā§āĻ­ āĻ“ āύ⧋āϟāĻŋāĻĢāĻŋāϕ⧇āĻļāύ āϏ⧇āĻ¨ā§āĻĄ try { await api.unsendMessage(loadingMsg.messageID); } catch(e) {} message.react("❌"); return message.reply(`❌ Failed to enhance the image.\n👉 Error: ${err.message}`); } } };