Skip to content

Commit

Permalink
[ Jessi-md 4.8.4 ⏱️ ]
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaweeshachamodx authored Jan 28, 2024
1 parent 86e28c3 commit f9cdb87
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions plugins/ai-gen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import fetch from 'node-fetch';

let handler = async (m, { conn, text, usedPrefix, command }) => {
if (!text) throw `*This command generates images from text prompts*\n\n*𝙴xample usage*\n*◉ ${usedPrefix + command} Beautiful anime girl*\n*◉ ${usedPrefix + command} Elon Musk in pink output*`;

try {
m.reply('*Generating images*');

const endpoint = `https://cute-tan-gorilla-yoke.cyclic.app/imagine?text=${encodeURIComponent(text)}`;
const response = await fetch(endpoint);

if (response.ok) {
const imageBuffer = await response.buffer();
await conn.sendFile(m.chat, imageBuffer, 'image.png', null, m);
} else {
throw '*Image generation failed*';
}
} catch {
throw '*❌ Error generating image.*';
}
};

handler.help = ['gen < text >'];
handler.tags = ['ai'];
handler.command = ['aiimg', 'gen', 'imagine'];
export default handler;

0 comments on commit f9cdb87

Please sign in to comment.