badgerealtime.js
memberikan sticker pada setiap pesan user yang masuk
JSJavaScriptPublicPluginsTanpa lisensiBaileys3 file · 266 baris · 7.2 KBDiperbarui 2 Nov 2026106 views
https://codeku.itsuki-nakano.my.id/repo/joootzyh/badgerealtime-jscurl -s https://codeku.itsuki-nakano.my.id/raw/joootzyh/badgerealtime-jsINFO BOT
- Nama bot
- LulliBot-md
- Versi
- 5.3.0
- Platform
- Baileys
Dependensi
@wiskeysocket/baileys
FILES
badge.js · javascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import { downloadContentFromMessage } from "@whiskeysockets/baileys";
export default {
run: async (m, sock) => {
let isSticker = false;
let stickerMessage = null;
if (
m.quoted &&
(m.quoted.mtype === "stickerMessage" || m.quoted.type === "stickerMessage")
) {
isSticker = true;
stickerMessage =
m.quoted.msg ||
m.quoted.message?.stickerMessage ||
m.quoted;
} else if (m.quoted?.message?.stickerMessage) {
isSticker = true;
stickerMessage = m.quoted.message.stickerMessage;
} else if (m.message?.extendedTextMessage?.contextInfo?.quotedMessage?.stickerMessage) {
isSticker = true;
stickerMessage =
m.message.extendedTextMessage.contextInfo.quotedMessage.stickerMessage;
}
if (!isSticker) {
return sock.sendMessage(
m.chat,
{
text:
"❌ Reply sebuah stiker untuk mengganti badge.\n\n" +
"Aktifkan reaction otomatis dengan *.badgerealtime on*."
},
{ quoted: m }
);
}
await sock.sendReact(m.chat, "⏱️", m.key).catch(() => {});
try {
let buffer;
if (m.quoted && typeof m.quoted.download === "function") {
buffer = await m.quoted.download();
} else {
const stream = await downloadContentFromMessage(stickerMessage, "sticker");
const chunks = [];
for await (const chunk of stream) chunks.push(chunk);
buffer = Buffer.concat(chunks);
}
if (!buffer?.length) {
throw new Error("Gagal mengunduh file stiker.");
}
const animated =
stickerMessage?.isAnimated ||
m.quoted?.isAnimated ||
false;
global.db.badge = {
buffer: buffer.toString("base64"),
isAnimated: animated,
updatedAt: Date.now()
};
await sock.sendReact(m.chat, "✅", m.key).catch(() => {});
return sock.sendMessage(
m.chat,
{
text:
`✅ *Badge berhasil diganti!*\n\n` +
`*Tipe:* ${animated ? "Animasi 🎞️" : "Statis 🖼️"}\n` +
`*Ukuran:* ${(buffer.length / 1024).toFixed(1)} KB\n\n` +
`Gunakan *.badgerealtime on/off* untuk mengatur reaction otomatis.`
},
{ quoted: m }
);
} catch (error) {
console.error("[BADGE ERROR]", error);
await sock.sendReact(m.chat, "❌", m.key).catch(() => {});
return sock.sendMessage(
m.chat,
{ text: `❌ Gagal menyimpan badge: ${error.message}` },
{ quoted: m }
);
}
},
cmd: "badge",
use: "(reply sticker)",
type: "owner",
owner: true,
location: "plugins/owner/badge.js"
};
badgerealtime.js · javascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/**
* Mengaktifkan atau menonaktifkan reaction sticker otomatis.
*
* Perintah:
* .badgerealtime on
* .badgerealtime off
*
* Pengaturan disimpan per sesi bot, bukan per grup.
*/
function normalizeJid(value = "") {
return String(value || "")
.split(":")[0]
.split("@")[0]
.replace(/\D/g, "");
}
function getBotSetting(sock) {
global.db = global.db || {};
global.db.setting = global.db.setting || {};
const botJid = sock?.user?.jid || sock?.user?.id || "";
if (!botJid) throw new Error("Identitas sesi bot tidak ditemukan.");
const number = normalizeJid(botJid);
const existingKey = Object.keys(global.db.setting).find(
key => normalizeJid(key) === number
);
const key = existingKey || botJid;
global.db.setting[key] = global.db.setting[key] || {};
return global.db.setting[key];
}
export default {
run: async (m, sock) => {
const action = String(m.text || "").trim().toLowerCase();
if (!["on", "off"].includes(action)) {
return m.reply(
`Gunakan:\n` +
`• *${m.prefix || "."}badgerealtime on*\n` +
`• *${m.prefix || "."}badgerealtime off*`
);
}
try {
const setting = getBotSetting(sock);
const nextState = action === "on";
const currentState = setting.badgerealtime === true;
if (currentState === nextState) {
return m.reply(
`✗ Badge Realtime was already ${nextState ? "active" : "inactive"} before.`
);
}
setting.badgerealtime = nextState;
return m.reply(
`✓ Badge Realtime successfully ${nextState ? "activated" : "deactivated"}.`
);
} catch (error) {
console.error("[BADGEREALTIME TOGGLE]", error);
return m.reply(`✗ Failed to update Badge Realtime: ${error.message}`);
}
},
cmd: "badgerealtime",
use: "on/off",
type: "owner",
owner: true,
location: "plugins/owner/badgerealtime.js"
};
PLAYGROUND
Siap
Klik Jalankan untuk melihat output.
Kode berjalan di kotak terisolasi di browser kamu. Tidak punya akses ke cookie, akun, atau server NAKANO CODE, dan tidak bisa membuka koneksi internet. Batas waktu 4 detik. Kode bot yang memanggil library WhatsApp (seperti Baileys) tidak bisa jalan di sini.