MCPcopy Create free account
hub / github.com/Maccoder3/MAC-MD / handler

Function handler

plugins/dalle.js:4–24  ·  view source on GitHub ↗
(m, { conn, text, usedPrefix, command })

Source from the content-addressed store, hash-verified

2import uploadImage from '../lib/uploadImage.js'
3
4let handler = async (m, { conn, text, usedPrefix, command }) => {
5 if (!text)
6 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*`
7
8 try {
9 m.reply('*Please wait, generating images...*')
10
11 const endpoint = `https://api.gurusensei.workers.dev/dream?prompt=${encodeURIComponent(text)}`
12 const response = await fetch(endpoint)
13
14 if (response.ok) {
15 const imageBuffer = await response.buffer()
16 let imgurl = await uploadImage(imageBuffer)
17 await conn.sendButton(m.chat,'Here is your Result', author, imgurl, [['Script', `.sc`]], null, [['Follow Me', `https://github.com/Guru322`]], m)
18 } else {
19 throw '*Image generation failed*'
20 }
21 } catch {
22 throw '*Oops! Something went wrong while generating images. Please try again later.*'
23 }
24}
25
26handler.help = ['dalle']
27handler.tags = ['AI']

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected