// code from goatstore // api: https://store.agi.bd const axios = require("axios"); const fs = require("fs-extra"); const path = require("path"); const { createCanvas, loadImage } = require("canvas"); module.exports = { config: { name: "bro", version: "2.0.2", author: "JUWEL | Fixed", countDown: 5, role: 0, shortDescription: "Create a beautiful brother banner", longDescription: "Create a brother banner with two profile pictures", category: "image", guide: "{pn} @mention or reply" }, onStart: async function ({ event, api, message }) { const { threadID, messageID, senderID, mentions, messageReply } = event; const targetID = String( Object.keys(mentions || {})[0] || messageReply?.senderID || "" ); if (!targetID) { return message.reply( "⚠️ কাউকে মেনশন করো অথবা তার মেসেজে রিপ্লাই দিয়ে bro লেখো!" ); } if (targetID === String(senderID)) { return message.reply( "😅 নিজের সাথে ব্রাদার ব্যানার বানানো যাবে না! অন্য কাউকে মেনশন করো।" ); } const cacheDir = path.join(__dirname, "cache"); await fs.ensureDir(cacheDir); const output = path.join( cacheDir, `bro_\( {Date.now()}_ \){senderID}.png` ); // Get user information const getUserInfo = (uid) => new Promise((resolve, reject) => { api.getUserInfo(String(uid), (err, data) => { if (err) return reject(err); const user = data && data[uid]; if (!user) { return reject(new Error("User information unavailable")); } resolve(user); }); }); // Download profile picture const getAvatar = async (uid, user) => { let url = user.thumbSrc || user.profileUrl; if (!url) { throw new Error(`Profile picture URL not found for user ${uid}`); } const response = await axios.get(url, { responseType: "arraybuffer", timeout: 20000, headers: { "User-Agent": "Mozilla/5.0" } }); return loadImage(Buffer.from(response.data)); }; try { const [senderInfo, targetInfo] = await Promise.all([ getUserInfo(senderID), getUserInfo(targetID) ]); const [senderAvatar, targetAvatar] = await Promise.all([ getAvatar(senderID, senderInfo), getAvatar(targetID, targetInfo) ]); // Canvas settings const width = 1000; const height = 650; const canvas = createCanvas(width, height); const ctx = canvas.getContext("2d"); // Background gradient const bg = ctx.createLinearGradient(0, 0, width, height); bg.addColorStop(0, "#16002f"); bg.addColorStop(0.5, "#5b167d"); bg.addColorStop(1, "#ff6699"); ctx.fillStyle = bg; ctx.fillRect(0, 0, width, height); // Decorative particles for (let i = 0; i < 65; i++) { const x = (i * 137 + 53) % width; const y = (i * 83 + 29) % height; const radius = 2 + (i % 4); ctx.beginPath(); ctx.arc(x, y, radius, 0, Math.PI * 2); ctx.fillStyle = "rgba(255,255,255,0.22)"; ctx.fill(); } // Main card ctx.fillStyle = "rgba(255,255,255,0.10)"; ctx.beginPath(); ctx.roundRect(45, 35, 910, 580, 35); ctx.fill(); ctx.strokeStyle = "rgba(255,255,255,0.4)"; ctx.lineWidth = 3; ctx.stroke(); // Title ctx.textAlign = "center"; ctx.textBaseline = "alphabetic"; ctx.fillStyle = "#ffffff"; ctx.font = "bold 50px Sans"; ctx.fillText("BROTHER FOREVER", 500, 115); ctx.fillStyle = "#ffe0ef"; ctx.font = "24px Sans"; ctx.fillText("ONE BOND • TWO BROTHERS", 500, 155); // Draw profile picture function drawAvatar(img, x, y, radius) { ctx.save(); // Outer ring ctx.beginPath(); ctx.arc(x, y, radius + 9, 0, Math.PI * 2); ctx.fillStyle = "#ffd5e8"; ctx.fill(); ctx.beginPath(); ctx.arc(x, y, radius + 4, 0, Math.PI * 2); ctx.fillStyle = "#ffffff"; ctx.fill(); // Circular clipping ctx.beginPath(); ctx.arc(x, y, radius, 0, Math.PI * 2); ctx.clip(); const scale = Math.max( (radius * 2) / img.width, (radius * 2) / img.height ); const w = img.width * scale; const h = img.height * scale; ctx.drawImage(img, x - w / 2, y - h / 2, w, h); ctx.restore(); } drawAvatar(senderAvatar, 300, 305, 105); drawAvatar(targetAvatar, 700, 305, 105); // Center symbol ctx.fillStyle = "#ffb8d5"; ctx.font = "bold 65px Sans"; ctx.fillText("♥", 500, 325); // Draw user names function drawName(name, x, y) { let text = String(name || "Brother"); if (text.length > 17) { text = text.substring(0, 15) + "..."; } ctx.fillStyle = "#ffffff"; ctx.font = "bold 28px Sans"; ctx.fillText(text, x, y); } drawName(senderInfo.name, 300, 460); drawName(targetInfo.name, 700, 460); // Bottom text ctx.fillStyle = "#ffe0ef"; ctx.font = "22px Sans"; ctx.fillText("True Brothers Never Leave Each Other", 500, 560); // Save image const buffer = canvas.toBuffer("image/png"); await fs.writeFile(output, buffer); // Send the image await message.reply({ body: "🖤 Brother Forever 🖤", attachment: fs.createReadStream(output) }); // Delete temporary file await fs.unlink(output).catch(() => {}); } catch (err) { console.error(err); return message.reply( "❌ ব্যানার বানাতে সমস্যা হয়েছে! আবার চেষ্টা করো।" ); } } };