(sock, message, args, context)
| 38 | description: 'Generate an AI image based on your prompt', |
| 39 | usage: '.diffusion <prompt>', |
| 40 | async handler(sock, message, args, context) { |
| 41 | const chatId = context.chatId || message.key.remoteJid; |
| 42 | const imagePrompt = args.join(' ').trim(); |
| 43 | if (!imagePrompt) { |
| 44 | return sock.sendMessage(chatId, { text: '🎨 *AI Image Generator*\n\nUsage: `.diffusion <prompt>`\nExample: `.diffusion a beautiful sunset over mountains`' }, { quoted: message }); |
| 45 | } |
| 46 | await sock.sendMessage(chatId, { react: { text: '🎨', key: message.key } }); |
| 47 | await sock.sendMessage(chatId, { text: '🎨 Generating your image... Please wait.' }, { quoted: message }); |
| 48 | try { |
| 49 | const enhanced = enhancePrompt(imagePrompt); |
| 50 | const imageBuffer = await generateImage(enhanced); |
| 51 | await sock.sendMessage(chatId, { |
| 52 | image: imageBuffer, |
| 53 | caption: `🎨 *Generated Image*\n📝 Prompt: _${imagePrompt}_` |
| 54 | }, { quoted: message }); |
| 55 | } |
| 56 | catch (error) { |
| 57 | console.error('Imagine error:', error.message); |
| 58 | await sock.sendMessage(chatId, { text: '❌ Failed to generate image. Please try again later.' }, { quoted: message }); |
| 59 | } |
| 60 | } |
| 61 | }; |
nothing calls this directly
no test coverage detected