import { downloadContentFromMessage as e } from "@whiskeysockets/baileys"; function t(e) { return String(e || "").split(":")[0].split("@")[0].replace(/\D/g, "") } export default { run: async (a, s) => { const n = a.chat, o = String(a.text || "").trim().toLowerCase(); if (/^(on|off|status)$/.test(o)) { const e = function(e) { global.db.setting = global.db.setting || {}; const a = e?.user?.jid || e?.user?.id || "", s = t(a), n = Object.keys(global.db.setting).find(e => t(e) === s) || a; return global.db.setting[n] = global.db.setting[n] || {}, global.db.setting[n] }(s); "on" === o ? e.autobadge = !0 : "off" === o && (e.autobadge = !1); const d = !1 === e.autobadge ? "OFF" : "ON", g = "status" === o ? `ℹ️ *Auto Badge:* ${d}` : `✅ *Auto Badge ${d}*\nPengaturan hanya berlaku untuk bot ini.`; return s.sendMessage(n, { text: g }, { quoted: a }) } let d = !1, g = null; if (!a.quoted || "stickerMessage" !== a.quoted.mtype && "stickerMessage" !== a.quoted.type ? a.quoted?.message?.stickerMessage && (d = !0, g = a.quoted.message.stickerMessage) : (d = !0, g = a.quoted.msg || a.quoted.message?.stickerMessage || a.quoted), !d && a.message?.extendedTextMessage?.contextInfo?.quotedMessage?.stickerMessage && (d = !0, g = a.message.extendedTextMessage.contextInfo.quotedMessage.stickerMessage), !d) return s.sendMessage(n, { text: "❌ Reply sebuah stiker untuk mengganti badge.\n\nPengaturan: .badge on / off / status" }, { quoted: a }); await s.sendReact(n, "⏱️", a.key).catch(() => {}); try { let t; if (a.quoted && "function" == typeof a.quoted.download) t = await a.quoted.download(); else { const a = await e(g, "sticker"), s = []; for await (const e of a) s.push(e); t = Buffer.concat(s) } if (!t?.length) throw new Error("Gagal mengunduh file stiker."); const o = g?.isAnimated || a.quoted?.isAnimated || !1; global.db.badge = { buffer: t.toString("base64"), isAnimated: o, updatedAt: Date.now() }, await s.sendReact(n, "✅", a.key).catch(() => {}), await s.sendMessage(n, { text: `✅ *Badge berhasil diganti!*\n\n*Tipe:* ${o?"Animasi 🎞️":"Statis 🖼️"}\n*Ukuran:* ${(t.length/1024).toFixed(1)} KB\n\nPengaturan Auto Badge: .badge on / off / status` }, { quoted: a }) } catch (e) { console.error("[badge] Error:", e), await s.sendReact(n, "❌", a.key).catch(() => {}), await s.sendMessage(n, { text: `❌ Gagal menyimpan badge: ${e.message}` }, { quoted: a }) } }, cmd: "badge", use: "(reply stiker) / on / off / status", type: "owner", owner: !0, location: "plugins/owner/badge.js" }; }