// code from goatstore // api: https://store.agi.bd const axios = require("axios"); const fs = require("fs"); const path = require("path"); module.exports = { config: { name: "draw", aliases: ["imagine", "aiimg"], version: "1.0", author: "๐† แ๐’๐ˆ๐˜๐€๐Œ-๐‡๐€๐’๐€๐", role: 0, category: "ai", guide: { en: "Use {p}draw [prompt] to generate AI image." } }, onStart: async function ({ api, event, args }) { const prompt = args.join(" "); if (!prompt) { return api.sendMessage( `๐Ÿงšโ€โ™€๏ธ๐—ก๐—œ๐—๐—›๐—จ๐—  ๐—–๐—›๐—”๐—ง๐—•๐—ข๐—ง๐Ÿ‘‘\n` + `โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n` + `ยป โ„น๏ธ ๐—ฃ๐—น๐—ฒ๐—ฎ๐˜€๐—ฒ ๐—ฝ๐—ฟ๐—ผ๐˜ƒ๐—ถ๐—ฑ๐—ฒ ๐—ฎ ๐—ฝ๐—ฟ๐—ผ๐—บ๐—ฝ๐˜.\n` + `ยป ๐—˜๐˜…๐—ฎ๐—บ๐—ฝ๐—น๐—ฒ: #๐—ฑ๐—ฟ๐—ฎ๐˜„ ๐—ฎ๐—ป๐—ถ๐—บ๐—ฒ ๐—ฏ๐—ผ๐˜†\n` + `โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n` + `ยป ๐Ÿ‘‘๐† แ๐’๐ˆ๐˜๐€๐Œ-๐‡๐€๐’๐€๐`, event.threadID, event.messageID ); } api.setMessageReaction("๐ŸŽจ", event.messageID, () => {}, true); try { const cachePath = path.join(__dirname, "cache", `ai_img_${Date.now()}.png`); if (!fs.existsSync(path.join(__dirname, "cache"))) { fs.mkdirSync(path.join(__dirname, "cache")); } const apiUrl = `https://image.pollinations.ai/p/${encodeURIComponent(prompt)}?width=1024&height=1024&seed=${Math.floor(Math.random() * 100000)}`; const response = await axios({ url: apiUrl, method: "GET", responseType: "stream" }); const writer = fs.createWriteStream(cachePath); response.data.pipe(writer); writer.on("finish", () => { api.sendMessage( { body: `๐Ÿงšโ€โ™€๏ธ๐—ก๐—œ๐—๐—›๐—จ๐—  ๐—–๐—›๐—”๐—ง๐—•๐—ข๐—ง๐Ÿ‘‘\n` + `โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n` + `ยป ๐ŸŽจ ๐—œ๐—บ๐—ฎ๐—ด๐—ฒ ๐—š๐—ฒ๐—ป๐—ฒ๐—ฟ๐—ฎ๐˜๐—ฒ๐—ฑ ๐—ฆ๐˜‚๐—ฐ๐—ฐ๐—ฒ๐˜€๐˜€๐—ณ๐˜‚๐—น๐—น๐˜†!\n` + `ยป ๐Ÿ“ ๐—ฃ๐—ฟ๐—ผ๐—บ๐—ฝ๐˜: ${prompt}\n` + `โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n` + `ยป ๐Ÿ‘‘๐† แ๐’๐ˆ๐˜๐€๐Œ-๐‡๐€๐’๐€๐`, attachment: fs.createReadStream(cachePath) }, event.threadID, () => { if (fs.existsSync(cachePath)) { fs.unlinkSync(cachePath); } api.setMessageReaction("๐ŸŽ€", event.messageID, () => {}, true); }, event.messageID ); }); writer.on("error", (err) => { throw err; }); } catch (error) { console.error(error); api.sendMessage( `๐Ÿงšโ€โ™€๏ธ๐—ก๐—œ๐—๐—›๐—จ๐—  ๐—–๐—›๐—”๐—ง๐—•๐—ข๐—ง๐Ÿ‘‘\n` + `โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n` + `ยป โŒ ๐—™๐—ฎ๐—ถ๐—น๐—ฒ๐—ฑ ๐˜๐—ผ ๐—ด๐—ฒ๐—ป๐—ฒ๐—ฟ๐—ฎ๐˜๐—ฒ ๐—ถ๐—บ๐—ฎ๐—ด๐—ฒ.\n` + `โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n` + `ยป ๐Ÿ‘‘๐† แ๐’๐ˆ๐˜๐€๐Œ-๐‡๐€๐’๐€๐`, event.threadID, event.messageID ); } } };