Created
March 6, 2024 07:52
-
-
Save dipto-008/cb235764b83200591ca038f4f6426e51 to your computer and use it in GitHub Desktop.
Hey noob ๐๐
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const axios = require('axios'); | |
const fs = require('fs-extra'); | |
module.exports.config = { | |
name: "meta", | |
version: "1.0.0", | |
hasPermssion: 0, | |
credits: "dipto", | |
usePrefix: true, | |
description: "Meta AI Image Generator.", | |
commandCategory: "imagination", | |
cooldowns: 5 | |
}; | |
module.exports.run = async function ({ args, event, api }) { | |
try { | |
const prompt = args.join(" "); | |
const wait = await api.sendMessage("๐ช๐ฎ๐ถ๐ ๐ธ๐ผ๐ฟ๐ผ ๐๐ฎ๐ฏ๐ <๐", event.threadID); | |
const response = await axios.get(`https://all-image-genator-d1p.onrender.com/dipto/meta?prompt=${encodeURIComponent(prompt)}&key=dipto008`); | |
const data = response.data.imgUrls; | |
if (!data || data.length === 0) { | |
return api.sendMessage("Empty response or no images generated.",event.threadID,event.messageID); | |
} | |
const imgData = []; | |
for (let i = 0; i < data.length; i++) { | |
const imgUrl = data[i]; | |
const imgResponse = await axios.get(imgUrl, { responseType: 'arraybuffer' }); | |
const imgPath = (__dirname +`/cache/${i + 1}.jpg`); | |
await fs.outputFile(imgPath, imgResponse.data); | |
imgData.push(fs.createReadStream(imgPath)); | |
} | |
await api.unsendMessage(wait.messageID); | |
await api.sendMessage({ | |
body: `โ | Generated your images`, | |
attachment: imgData | |
}, event.threadID ,event.messageID); | |
for (const imgPath of imgData) { | |
fs.unlink(imgPath); | |
} | |
} catch (e) { | |
console.error(e); | |
await api.sendMessage(`Failed to genarate photo!!!!\nerror: ${e.message}`, event.threadID); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment