// code from goatstore // api: https://store.agi.bd const { createCanvas, loadImage } = require("canvas"); const fs = require("fs-extra"); const path = require("path"); module.exports = { config: { name: "chudle", version: "1.0", author: "Mehedi-saito", countDown: 5, role: 0, shortDescription: "Chudle meme generator", longDescription: "Generates a chudle meme - sender on happy emoji, target on cry emoji", category: "fun", guide: { en: "{pn} reply to someone's message or mention them\nExample: {pn} @Someone" } }, onStart: async function ({ api, event, usersData, message }) { const { threadID, messageID, senderID, type, messageReply, mentions } = event; let targetID; if (type === "message_reply") { targetID = messageReply.senderID; } else if (mentions && Object.keys(mentions).length > 0) { targetID = Object.keys(mentions)[0]; } if (!targetID) { return message.reply( "❌ Please reply to someone's message or mention them to use this command." ); } if (targetID === senderID) { return message.reply("❌ You can't use this command on yourself."); } try { const templateUrl = "https://drive.google.com/uc?export=download&id=15sNWni3nSzQF0033_WBzDhUpJcCta-3o"; // Sender (command user) avatar const avatarSenderUrl = `https://graph.facebook.com/${senderID}/picture?width=512&height=512&access_token=6628568379%7Cc1e620fa708a1d5696fb991c1bde5662`; // Target (replied/mentioned) avatar const avatarTargetUrl = `https://graph.facebook.com/${targetID}/picture?width=512&height=512&access_token=6628568379%7Cc1e620fa708a1d5696fb991c1bde5662`; const [template, avatarSender, avatarTarget] = await Promise.all([ loadImage(templateUrl), loadImage(avatarSenderUrl), loadImage(avatarTargetUrl) ]); // Canvas size matching original image (598 x 480) const canvas = createCanvas(598, 480); const ctx = canvas.getContext("2d"); // Draw background template ctx.drawImage(template, 0, 0, 598, 480); // Draw avatar in circle function const drawAvatarInCircle = (img, cx, cy, radius) => { ctx.save(); ctx.beginPath(); ctx.arc(cx, cy, radius, 0, Math.PI * 2); ctx.closePath(); ctx.clip(); ctx.drawImage( img, cx - radius, cy - radius, radius * 2, radius * 2 ); ctx.restore(); }; // White border around avatar const drawCircleBorder = (cx, cy, radius) => { ctx.beginPath(); ctx.arc(cx, cy, radius + 2, 0, Math.PI * 2); ctx.strokeStyle = "#FFFFFF"; ctx.lineWidth = 4; ctx.stroke(); }; // Left smiling emoji → Sender (command user) - higher + more right const senderCx = 190; const senderCy = 85; const senderRadius = 65; // Right crying emoji → Target (replied/mentioned) - moved higher const targetCx = 450; const targetCy = 85; const targetRadius = 65; // Draw sender on left (happy emoji) drawCircleBorder(senderCx, senderCy, senderRadius); drawAvatarInCircle(avatarSender, senderCx, senderCy, senderRadius); // Draw target on right (cry emoji) drawCircleBorder(targetCx, targetCy, targetRadius); drawAvatarInCircle(avatarTarget, targetCx, targetCy, targetRadius); // ===== Flowers Effect ===== const drawFlower = (x, y, size, color) => { // Petals ctx.fillStyle = color; for (let i = 0; i < 5; i++) { const angle = (i * Math.PI * 2) / 5 - Math.PI / 2; const px = x + Math.cos(angle) * size * 0.6; const py = y + Math.sin(angle) * size * 0.6; ctx.beginPath(); ctx.arc(px, py, size * 0.45, 0, Math.PI * 2); ctx.fill(); } // Center ctx.fillStyle = "#FFD700"; ctx.beginPath(); ctx.arc(x, y, size * 0.3, 0, Math.PI * 2); ctx.fill(); }; // Draw flowers around the image (corners & sides) const flowerColors = ["#FF69B4", "#FF1493", "#FFB6C1", "#FF85A2", "#FF6B9D"]; // Top left drawFlower(40, 40, 18, flowerColors[0]); drawFlower(80, 25, 14, flowerColors[1]); // Top right drawFlower(558, 40, 18, flowerColors[2]); drawFlower(520, 25, 14, flowerColors[3]); // Bottom left drawFlower(40, 440, 16, flowerColors[4]); drawFlower(75, 455, 13, flowerColors[0]); // Bottom right drawFlower(558, 440, 16, flowerColors[1]); drawFlower(520, 455, 13, flowerColors[2]); // Extra small flowers drawFlower(30, 200, 12, flowerColors[3]); drawFlower(568, 200, 12, flowerColors[4]); drawFlower(30, 320, 11, flowerColors[0]); drawFlower(568, 320, 11, flowerColors[1]); const cacheDir = path.join(__dirname, "cache"); await fs.ensureDir(cacheDir); const filePath = path.join(cacheDir, `chudle_${senderID}.png`); await fs.writeFile(filePath, canvas.toBuffer("image/png")); await message.reply({ body: "Chudley Moja 🌚🍼", attachment: fs.createReadStream(filePath) }); fs.unlink(filePath, () => {}); } catch (err) { console.error("[CHUDLE ERROR]", err); return message.reply("❌ Failed to generate the image. Please try again."); } } };