Import { Generatewamessagecontent Generatewamessagefromcontent } From @whiskeysockets/baileys; Import

Description

import { generatewamessagecontent, generatewamessagefromcontent } from "@whiskeysockets/baileys"; import crypto from "crypto"; // --- fungsi helper: membuat protokol group status v2 --- async function sendgroupstatus(client, jid, content) { let { backgroundcolor } = content; // hapus bg color dari content agar tidak error saat generate if (content.backgroundcolor) delete content.backgroundcolor; // 1. generate konten (upload media jika ada) const inside = await generatewamessagecontent(content, { upload: client.wauploadtoserver }); // 2. tambahkan background color (wajib untuk status teks) // jika teks dan tidak ada warna, kita kasih warna random if (content.text && !backgroundcolor) { const colors = [0xff792139, 0xff243640, 0xff37213e, 0xff213c32, 0xff546e7a]; backgroundcolor = colors[math.floor(math.random() * colors.length)]; } if (backgroundcolor) { inside.backgroundcolor = backgroundcolor; } // 3. buat message secret (enkripsi) const messagesecret = crypto.randombytes(32); // 4. susun pesan protobuf const msg = generatewamessagefromcontent( jid, { messagecontextinfo: { messagesecret }, groupstatusmessagev2: { message: { ...inside, messagecontextinfo: { messagesecret } } } }, { userjid: client.user.id } // pastikan pengirim teridentifikasi ); // 5. kirim via relay await client.relaymessage(jid, msg.message, { messageid: msg.key.id }); return msg; } // --- handler --- export default { name: "upswgc", aliases: ["gcupsw", "swgc", "statusgc"], category: "group", desc: "send real group status (v2)", usage: "upswgc <text/reply media>", grouponly: true, // fitur ini khusus untuk di dalam grup async execute({ m, sock, conn, text, reply, prefix, command }) { const client = sock || conn; try { const q = m.quoted ? m.quoted : m; const mime = (q.msg || q).mimetype || ""; // ambil caption/teks // jika reply text, ambil text reply-nya. jika tidak, ambil argumen setelah command. let caption = text; if (!mime && !caption && m.quoted && m.quoted.text) { caption = m.quoted.text; } // validasi input if (!mime && !caption) { return await reply( `❌ reply media atau ketik teks.\n\n*contoh:*\n${prefix + command} hello world\n${prefix + command} (sambil reply )` ); } await m.react("⏳"); let payload = {}; // deteksi tipe konten if (/image/.test(mime)) { payload = { image: await q.download(), caption: caption }; } else if (/video/.test(mime)) { payload = { video: await q.download(), caption: caption }; } else if (/audio/.test(mime)) { payload = { audio: await q.download(), mimetype: "audio/mp4", // ptt: true // opsional: aktifkan jika ingin jadi vn }; } else { // status teks payload = { text: caption, // font: 3 // opsional: font style }; } // eksekusi pengiriman await sendgroupstatus(client, m.chat, payload); await m.react("✅"); } catch (e) { console.error("upswgc error:", e); await m.react("❌"); await reply("❌ terjadi kesalahan saat mengirim status grup."); } } };

Created On

23.12.2025 16:11

Download

Related Images