Skip to content

Instantly share code, notes, and snippets.

@dipto-008
Created March 6, 2024 08:06
Show Gist options
  • Save dipto-008/309a9d22144b001cf4c82b82b8613195 to your computer and use it in GitHub Desktop.
Save dipto-008/309a9d22144b001cf4c82b82b8613195 to your computer and use it in GitHub Desktop.
Hey noob πŸ‘‹πŸ‘‹
const axios = require('axios');
const fs = require('fs-extra');
const path = require('path');
module.exports.config = {
name: "dalle",
version: "1.0",
credits: "dipto",
hasPermssion: 0,
usePrefix: true,
premium: true,
description: "Generate images by Dalle-3 AI",
commandCategory: "download",
usages: "[text] \nJamon [A 17/18/19 years old boy/girl watching football match on tv and written Dipto and 69 on the back of his Dress , 4k]",
cooldowns: 5
};
module.exports.run = async function ({ api, event, args }) {
const prompt = event.messageReply?.body.split("dalle")[1] || args.join(" ");
if (!prompt) {
return api.sendMessage("❌| Wrong Formet .βœ… | Use 17/18 years old boy/girl watching football match on tv and written Dipto and 69 on the back of his Dress , 4k",event.threadID,event.messageID);
}
try {
const w = await api.sendMessage("Wait koro baby < 😽", event.threadID);
const response = await axios.get(`https://all-image-genator-d1p.onrender.com/dipto/dalle?prompt=${prompt}&key=dipto008`)
const data = response.data.imgUrls;
if (!data || data.length === 0) {
api.sendMessage("Empty response or no images generated.",event.threadID,event.messageID);
}
const diptoo = [];
for (let i = 0; i < data.length; i++) {
const imgUrl = data[i];
const imgResponse = await axios.get(imgUrl, { responseType: 'arraybuffer' });
const imgPath = path.join(__dirname, 'dalle', `${i + 1}.jpg`);
await fs.outputFile(imgPath, imgResponse.data);
diptoo.push(fs.createReadStream(imgPath));
}
await api.unsendMessage(w.messageID);
await api.sendMessage({
body: `βœ… |Naw Baby Tumar Generated Pic<😘`,
attachment: diptoo
},event.threadID, event.messageID);
} catch (error) {
console.error(error);
await api.sendMessage(`Generation failed!\nError: ${error.message}`,event.threadID, event.messageID);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment