-
-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
86e28c3
commit f9cdb87
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
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; |