baileys-yorkv2
v1.0.35
Published
Enhanced Baileys v2 with fixes for newsletter media uploads, plus support for interactive messages, albums, and additional message types.
Downloads
5,949
Maintainers
Readme
📣 riyoo
✨ Fitur Utama
- 🔧 Fix LID/PN JID handling untuk grup (addressing mode
lid&s.whatsapp.net/@g.us) - 🚫 Tanpa obfuscation — kode mudah dibaca dan diaudit
- 🚫 Tanpa auto-follow channel (newsletter)
- 📦 Includes
makeInMemoryStoredengan adaptasi ESM minimal - 🖼️ Support multi image processing backend:
sharp,@napi-rs/image, ataujimp - 📦 FFmpeg menggunakan
spawn(lebih aman dariexec)
🛠️ Perbaikan Internal
- 🔑 Fix variable shadowing
isLidUserdigetUSyncDevices— mencegah konflik antara variabel lokal dan fungsi import - 📍 Fix server encoding untuk
@lidJID — memastikan JID yang diminta sebagai LID tetap@lid, bukan berubah jadi@s.whatsapp.net - 👥 Fix participant list di grup — null-check eksplisit, normalisasi JID via
jidNormalizedUser, dan cross-field validation antaraphoneNumberdanlid - 🔊 Fix ptt: true, stabil no error
- 🖼️ Fix media upload ke newsletter
- 🔒 Fix
updateBlockStatusimplementation
📨 Tipe Pesan yang Didukung
- 🖼️ Album (Image & Video)
- 👥 Group Status Message
- 👉🏻 Interactive Message (buttons, list, native flow, template, carousel)
- 🧩 Interactive Message Raw (native flow penuh:
cta_copy,cta_url,cta_call,quick_reply,single_select,call_permission_request) - 🎞️ Status Mention Message
- 📦 Sticker Pack Message
- ✨ Rich Response Message
- 🧾 Message with Code Block
- 🌏 Message with Inline Entities
- 📋 Message with Table
- 💳 Payment-related Message (request, invite, order, invoice)
- 🎠 Carousel Message
- 🤖 Rich Response / AI Message (code block, table, inline link)
- 🎥 PTV (Circle Video / Picture-in-Picture)
- 👥 Group Invite Link Message
- 📞 Share / Request Phone Number
- 🗳️ Quiz (Poll with correct answer)
- 📊 Poll Result Snapshot
📋 Daftar Isi
- 📥 Instalasi
- 🌐 Koneksi ke WhatsApp
- 🗄️ Data Store
- 🪪 Penjelasan WhatsApp ID
- 🌏 Message with Inline Entities
- 🗓️ Event
- ✉️ Mengirim Pesan
- 📁 Mengirim Media
- 👉🏻 Pesan Interaktif
- 🧩 Interactive Message Raw
- 💳 Pesan Pembayaran
- 🛒 Pesan Order & Invoice
- 👁️ Opsi Pesan Lainnya
- ♻️ Modifikasi Pesan
- ↩️ Pesan Balasan Interaktif
- 🧰 Konten Tambahan
- 📣 Credits
📥 Instalasi
# Via NPM
npm i baileys-yorkv2
# Via GitHub
npm i github:baileys-yorkv2 ( gada repo nya yaa )// package.json
"dependencies": {
"baileys-yorkv2": "latest"
}🧩 Import (ESM & CJS)
// ESM
import { makeWASocket } from 'baileys-yorkv2'
// CJS
const { makeWASocket } = require('baileys-yorkv2')🌐 Koneksi ke WhatsApp
import { makeWASocket, delay, DisconnectReason, useMultiFileAuthState } from 'baileys-yorkv2'
import { Boom } from '@hapi/boom'
import pino from 'pino'
const myPhoneNumber = '6288888888888'
const logger = pino({ level: 'silent' })
const connectToWhatsApp = async () => {
const { state, saveCreds } = await useMultiFileAuthState('session')
const sock = makeWASocket({
logger,
auth: state
})
sock.ev.on('creds.update', saveCreds)
sock.ev.on('connection.update', async (update) => {
const { connection, lastDisconnect } = update
if (connection === 'connecting' && !sock.authState.creds.registered) {
await delay(1500)
const code = await sock.requestPairingCode(myPhoneNumber)
console.log('🔗 Pairing code:', code)
}
else if (connection === 'close') {
const shouldReconnect = new Boom(lastDisconnect?.error)?.output?.statusCode !== DisconnectReason.loggedOut
if (shouldReconnect) connectToWhatsApp()
}
else if (connection === 'open') {
console.log('✅ Terhubung ke WhatsApp')
}
})
sock.ev.on('messages.upsert', async ({ messages }) => {
for (const message of messages) {
if (!message.message) continue
await sock.sendMessage(message.key.remoteJid, { text: '👋🏻 Halo!' })
}
})
}
connectToWhatsApp()🔐 Auth State
[!NOTE] Bisa juga pakai
useSingleFileAuthStateatauuseSqliteAuthStatesebagai alternatif dariuseMultiFileAuthState.
🗄️ Data Store
[!CAUTION] Sangat disarankan membangun data store sendiri — menyimpan seluruh riwayat chat di memori bisa menyebabkan penggunaan RAM yang berlebihan.
import { makeWASocket, makeInMemoryStore, useMultiFileAuthState } from 'baileys-yorkv2'
import pino from 'pino'
const logger = pino({ level: 'silent' })
const storePath = './store.json'
const connectToWhatsApp = async () => {
const { state, saveCreds } = await useMultiFileAuthState('session')
const sock = makeWASocket({ logger, auth: state })
const store = makeInMemoryStore({ logger, socket: sock })
store.bind(sock.ev)
store.readFromFile(storePath)
setInterval(() => store.writeToFile(storePath), 180_000)
sock.ev.on('creds.update', saveCreds)
}
connectToWhatsApp()🪪 Penjelasan WhatsApp ID
jid adalah ID WhatsApp pengguna atau grup.
- Pengguna PN:
[email protected] - Pengguna LID:
43411111111111@lid - Grup:
[email protected] - Meta AI:
11111111111@bot - Broadcast list:
[timestamp]@broadcast - Stories:
status@broadcast - Newsletter:
1231111111111@newsletter
[!NOTE] Nomor telepon harus menggunakan format internasional tanpa
+,(), atau-.
✉️ Mengirim Pesan
🔠 Teks
// Teks biasa
sock.sendMessage(jid, { text: '👋🏻 Halo' }, { quoted: message })
// Teks dengan link preview
sock.sendMessage(jid, {
text: 'https://github.com — cek ini!',
linkPreview: {
'matched-text': 'https://github.com',
title: 'GitHub',
description: 'Where the world builds software',
previewType: 0
}
})🌏 Message with Inline Entities
sock.sendMessage(jid, {
disclaimerText: 'Inline Entities',
headerText: '## Check Out!',
contentText: '---',
links: [{
text: '1. Google',
title: 'Popular Search Engine',
url: 'https://www.google.com/'
}, {
text: '2. YouTube',
title: 'Popular Streaming Platform',
url: 'https://www.youtube.com/'
}, {
text: '3. Modded Baileys',
title: 'Underrated Baileys Fork',
url: 'https://www.npmjs.com/package/@baileys-yorkv2'
}],
footerText: '---'
})🔔 Mention
// Mention spesifik
sock.sendMessage(jid, {
text: '👋🏻 Halo @628123456789',
mentions: ['[email protected]']
}, { quoted: message })
// Mention semua
sock.sendMessage(jid, {
text: '👋🏻 Halo @all',
mentionAll: true
}, { quoted: message })😁 Reaksi
sock.sendMessage(jid, {
react: { key: message.key, text: '✨' }
})📌 Pin Pesan
sock.sendMessage(jid, {
pin: message.key,
time: 86400, // detik: 86400 (1h), 604800 (7h), 2592000 (30h)
type: 1 // 2 untuk unpin
})🔖 Keep Chat
[!NOTE] Hanya untuk chat dengan disappearing messages aktif.
sock.sendMessage(jid, { keep: message.key, type: 1 }) // type: 2 untuk remove➡️ Forward
sock.sendMessage(jid, { forward: message, force: true })👤 Kontak
const vcard = 'BEGIN:VCARD\nVERSION:3.0\nFN:Nama Kontak\nTEL;type=CELL;waid=628123456789:+62 8123 456 789\nEND:VCARD'
sock.sendMessage(jid, {
contacts: {
displayName: 'Nama Kontak',
contacts: [{ vcard }]
}
}, { quoted: message })📍 Lokasi
sock.sendMessage(jid, {
location: {
degreesLatitude: -6.2,
degreesLongitude: 106.8,
name: '📍 Jakarta'
}
}, { quoted: message })🗓️ Event
sock.sendMessage(jid, {
event: {
name: '🎉 Acara Seru',
description: 'Deskripsi acara di sini.',
startDate: new Date(Date.now() + 3_600_000),
endDate: new Date(Date.now() + 28_800_000),
location: { name: 'Jakarta', degreesLatitude: -6.2, degreesLongitude: 106.8 }
}
}, { quoted: message })📊 Polling
sock.sendMessage(jid, {
poll: {
name: '🔥 Pilih satu!',
values: ['Ya', 'Tidak'],
selectableCount: 1,
endDate: new Date(Date.now() + 28_800_000)
}
}, { quoted: message })🗳️ Quiz (Newsletter)
[!NOTE] Hanya berfungsi di newsletter (
@newsletter).
sock.sendMessage(jid, {
poll: {
name: '❓ Ibu kota Indonesia?',
values: ['Jakarta', 'Bandung', 'Surabaya', 'Nusantara'],
pollType: 1, // 1 = quiz
correctAnswer: 'Nusantara'
}
}, { quoted: message })📁 Mengirim Media
[!NOTE] Media bisa berupa
Buffer,{ stream: Readable }, atau{ url: string }(path lokal atau URL HTTP/HTTPS).
🖼️ Gambar
sock.sendMessage(jid, {
image: { url: './path/to/image.jpg' },
caption: '🔥 Keren!'
}, { quoted: message })🎥 Video
sock.sendMessage(jid, {
video: { url: './path/to/video.mp4' },
gifPlayback: false,
caption: '🎬 Video keren!'
}, { quoted: message })📃 Stiker
sock.sendMessage(jid, {
sticker: { url: './path/to/sticker.webp' }
}, { quoted: message })💽 Audio
sock.sendMessage(jid, {
audio: { url: './path/to/audio.mp3' },
ptt: false // true = Voice Note
}, { quoted: message })🗂️ Dokumen
sock.sendMessage(jid, {
document: { url: './path/to/file.pdf' },
mimetype: 'application/pdf',
caption: '📄 Dokumen saya'
}, { quoted: message })🖼️ Album (Gambar & Video)
sock.sendMessage(jid, {
album: [
{ image: { url: './image1.jpg' }, caption: 'Foto 1' },
{ video: { url: './video1.mp4' }, caption: 'Video 1' },
{ image: { url: './image2.jpg' }, caption: 'Foto 2' }
]
}, { quoted: message })📦 Sticker Pack
[!IMPORTANT] Jika
sharpatau@napi-rs/imagetidak terpasang,coverdanstickersharus sudah dalam format WebP.
sock.sendMessage(jid, {
cover: { url: './cover.webp' },
stickers: [
{ data: { url: './sticker1.webp' } },
{ data: { url: './sticker2.webp' } }
],
name: '📦 Sticker Pack Ku',
publisher: '🌟 Nama Kamu'
}, { quoted: message })🎥 PTV (Circle Video)
sock.sendMessage(jid, {
video: { url: './path/to/video.mp4' },
ptv: true
}, { quoted: message })👉🏻 Pesan Interaktif
🔘 Tombol (Buttons)
sock.sendMessage(jid, {
text: '👆🏻 Pilih opsi:',
footer: 'riyoo',
buttons: [
{ text: '👋🏻 Halo', id: '#Halo' },
{ text: '❓ Bantuan', id: '#Bantuan' }
]
}, { quoted: message })📋 List
[!NOTE] Hanya berfungsi di chat pribadi (
@s.whatsapp.net).
sock.sendMessage(jid, {
text: '📋 Menu',
footer: 'riyoo',
buttonText: '📋 Pilih',
sections: [{
title: '🚀 Menu Utama',
rows: [
{ title: '✨ Fitur A', description: '', rowId: '#FiturA' },
{ title: '🔍 Cari', description: '', rowId: '#Cari' }
]
}]
}, { quoted: message })🗄️ Interactive (Native Flow)
sock.sendMessage(jid, {
image: { url: './image.jpg' },
caption: '🗄️ Menu Interaktif',
footer: 'riyoo',
nativeFlow: [
{ text: '👋🏻 Sapa', id: '#Sapa', icon: 'review' },
{ text: '🌐 Website', url: 'https://github.com', useWebview: true },
{ text: '📋 Salin', copy: 'teks yang disalin' },
{ text: '📞 Hubungi', call: '628123456789' }
]
}, { quoted: message })🫙 Template
sock.sendMessage(jid, {
title: '👋🏻 Halo',
image: { url: './image.jpg' },
caption: '🫙 Template',
footer: 'riyoo',
templateButtons: [
{ text: '👉🏻 Tap', id: '#Tap' },
{ text: '🌐 Buka', url: 'https://github.com' },
{ text: '📞 Telepon', call: '628123456789' }
]
}, { quoted: message })🧩 Interactive Message Raw (Native Flow Penuh)
Gunakan interactiveMessage langsung untuk kontrol penuh atas struktur pesan — mendukung nativeFlowMessage dengan messageParamsJson kustom, bottom_sheet, limited_time_offer, tap_target_configuration, call_permission_request, dan kombinasi tombol kompleks.
sock.sendMessage(jid, {
interactiveMessage: {
title: '📋 Judul Pesan',
footer: 'Footer Pesan',
thumbnail: 'https://example.com/image.jpg', // URL string, Buffer, atau { url }
nativeFlowMessage: {
messageParamsJson: JSON.stringify({
limited_time_offer: {
text: 'Penawaran Terbatas',
url: 'https://example.com',
copy_code: 'KODE123',
expiration_time: Date.now() + 3_600_000
},
bottom_sheet: {
in_thread_buttons_limit: 2,
divider_indices: [1, 2, 3],
list_title: 'Pilih Menu',
button_title: '📋 Buka Menu'
},
tap_target_configuration: {
title: '▸ Info ◂',
description: 'Deskripsi',
canonical_url: '',
domain: 'shop.example.com',
button_index: 0
}
}),
buttons: [
// Tombol izin panggilan
{
name: 'call_permission_request',
buttonParamsJson: JSON.stringify({ has_multiple_buttons: true })
},
// Tombol list/pilihan
{
name: 'single_select',
buttonParamsJson: JSON.stringify({
title: '📋 Pilih Opsi',
sections: [{
title: 'Menu Utama',
highlight_label: 'Home',
rows: [
{ title: 'Fitur A', description: 'Deskripsi A', id: '#FiturA' },
{ title: 'Fitur B', description: 'Deskripsi B', id: '#FiturB' }
]
}],
has_multiple_buttons: true
})
},
// Tombol URL
{
name: 'cta_url',
buttonParamsJson: JSON.stringify({
display_text: '🌐 Kunjungi',
url: 'https://example.com',
merchant_url: 'https://example.com'
})
},
// Tombol salin kode
{
name: 'cta_copy',
buttonParamsJson: JSON.stringify({
display_text: '📋 Salin Kode',
copy_code: 'KODE123'
})
},
// Tombol telepon
{
name: 'cta_call',
buttonParamsJson: JSON.stringify({
display_text: '📞 Hubungi',
phone_number: '628123456789'
})
},
// Tombol quick reply
{
name: 'quick_reply',
buttonParamsJson: JSON.stringify({
display_text: '👉🏻 Balas',
id: '#Balas'
})
}
]
},
contextInfo: {
mentionedJid: ['[email protected]'],
isForwarded: true,
forwardedNewsletterMessageInfo: {
newsletterJid: '1231111111111@newsletter',
newsletterName: 'Channel Name',
serverMessageId: -1
}
}
}
}, { quoted: message })[!NOTE] Semua nama tombol yang valid:
quick_reply,cta_url,cta_copy,cta_call,single_select,call_permission_request. Fieldthumbnailbisa berupa string URL,Buffer, atau objek{ url: '...' }.
🎠 Carousel
sock.sendMessage(jid, {
text: '🎠 Pilih kartu:',
footer: 'riyoo',
cards: [
{
image: { url: './image1.jpg' },
caption: '🃏 Kartu 1',
footer: 'Footer kartu 1',
nativeFlow: [
{ text: '👉🏻 Pilih', id: '#Kartu1' },
{ text: '🌐 Info', url: 'https://example.com' }
]
},
{
image: { url: './image2.jpg' },
caption: '🃏 Kartu 2',
footer: 'Footer kartu 2',
nativeFlow: [
{ text: '👉🏻 Pilih', id: '#Kartu2' }
]
}
]
}, { quoted: message })👥 Group Invite Link
sock.sendMessage(jid, {
groupInvite: {
jid: '[email protected]',
subject: 'Nama Grup',
inviteCode: 'XXXXXXXXXXXX',
inviteExpiration: Date.now() + 86_400_000,
text: '🔗 Bergabunglah!'
}
}, { quoted: message })💳 Pesan Pembayaran
// Undang pembayaran
sock.sendMessage(jid, { paymentInviteServiceType: 3 })
// Request pembayaran
sock.sendMessage(jid, {
text: '💳 Request Pembayaran',
requestPaymentFrom: '[email protected]'
})🛒 Pesan Order & Invoice
📦 Order Message
[!IMPORTANT] Field
thumbnailwajib berupaBuffer.
import fs from 'fs'
sock.sendMessage(jid, {
orderText: 'Pesanan kamu sudah siap!',
thumbnail: fs.readFileSync('./product.jpg'),
itemCount: 2,
totalAmount1000: 50000, // harga × 1000 (Rp 50.000)
totalCurrencyCode: 'IDR'
}, { quoted: message })🧾 Invoice Message
[!IMPORTANT] Harus disertai media (
imageataudocument) sebeluminvoiceNote.
sock.sendMessage(jid, {
image: { url: './invoice.jpg' },
invoiceNote: '🧾 Invoice #001 — Terima kasih telah berbelanja!'
}, { quoted: message })👁️ Opsi Pesan Lainnya
🤖 Ikon AI
[!NOTE] Hanya berfungsi di chat pribadi (
@s.whatsapp.net).
sock.sendMessage(jid, {
image: { url: './image.jpg' },
caption: '🤖 Pesan AI',
ai: true
})🎨 Warna Latar & Font Teks
// Warna latar (status / ptt)
sock.sendMessage(jid, {
text: '🎨 Pesan berwarna',
backgroundColor: '#FF6B6B' // hex color string
})
// Font kustom
sock.sendMessage(jid, {
text: '✍️ Font kustom',
font: 1 // 1–8, lihat WAProto ExtendedTextMessage.FontType
})🌐 Favicon Teks
import fs from 'fs'
sock.sendMessage(jid, {
text: 'Cek https://example.com',
favicon: fs.readFileSync('./favicon.png') // Buffer favicon
})📊 Group Status
Tandai pesan agar tampil sebagai pesan status grup (muncul di sistem grup).
sock.sendMessage(jid, {
text: '📢 Pengumuman grup',
groupStatus: true
})📞 Berbagi / Minta Nomor Telepon
// Kirim nomor kamu ke lawan bicara
sock.sendMessage(jid, { sharePhoneNumber: true })
// Minta nomor telepon lawan bicara
sock.sendMessage(jid, { requestPhoneNumber: true })
// Batasi berbagi (limit sharing)
sock.sendMessage(jid, { limitSharing: true }) // true = batasi, false = buka📑 Spoiler
sock.sendMessage(jid, {
image: { url: './image.jpg' },
caption: '❔ Spoiler nih',
spoiler: true
})👁️ View Once
sock.sendMessage(jid, {
image: { url: './image.jpg' },
caption: '👁️ Lihat sekali saja',
viewOnce: true
})🕒 Ephemeral
sock.sendMessage(jid, {
image: { url: './image.jpg' },
caption: '🕒 Ephemeral',
ephemeral: true
})📰 External Ad Reply
sock.sendMessage(jid, {
text: '📰 External Ad',
externalAdReply: {
title: '📝 Info Menarik',
body: 'Cek ini!',
thumbnail: fs.readFileSync('./thumb.jpg'),
largeThumbnail: false,
url: 'https://github.com'
}
}, { quoted: message })🧩 Raw
sock.sendMessage(jid, {
extendedTextMessage: {
text: '📃 Dibuat manual dari struktur proto WhatsApp',
contextInfo: {
externalAdReply: {
title: 'riyoo',
thumbnail: fs.readFileSync('./thumb.jpg'),
sourceApp: 'whatsapp',
showAdAttribution: true,
mediaType: 1
}
}
},
raw: true
}, { quoted: message })♻️ Modifikasi Pesan
🗑️ Hapus Pesan
sock.sendMessage(jid, { delete: message.key })✏️ Edit Pesan
// Edit teks
sock.sendMessage(jid, { text: '✨ Sudah diedit!', edit: message.key })
// Edit caption media
sock.sendMessage(jid, { caption: '✨ Caption baru', edit: message.key })↩️ Pesan Balasan Interaktif
🔘 Button Reply
// Template button reply
sock.sendMessage(jid, {
buttonReply: {
displayText: '👉🏻 Tap',
id: '#Tap',
index: 0
},
type: 'template'
})
// Plain button reply
sock.sendMessage(jid, {
buttonReply: {
displayText: '👉🏻 Tap',
id: '#Tap'
},
type: 'plain'
})📋 List Reply
sock.sendMessage(jid, {
listReply: {
title: '✨ Fitur A',
description: 'Kamu memilih Fitur A',
id: '#FiturA'
}
})🗄️ Flow Reply (Native Flow Response)
sock.sendMessage(jid, {
flowReply: {
name: 'quick_reply',
paramsJson: JSON.stringify({ id: '#Pilihan1', display_text: 'Pilihan 1' }),
text: 'Saya memilih ini',
version: 3
}
})🧰 Konten Tambahan
🏷️ Cari User ID (JID | PN / LID)
// Via PN
const ids = await sock.findUserId('[email protected]')
console.log('🏷️ User ID:', ids)
// Output: { phoneNumber: '[email protected]', lid: '43411111111111@lid' }
// Via LID
const ids = await sock.findUserId('43411111111111@lid')
console.log('🏷️ User ID:', ids)🔑 Pairing Code Kustom
const code = await sock.requestPairingCode('6281111111111', 'CUSTOMKODE')
console.log('🔗 Pairing code:', code)🖼️ Image Processing
import { getImageProcessingLibrary } from 'riyoo'
import { readFile } from 'fs/promises'
const lib = await getImageProcessingLibrary()
const width = 512
if (lib.sharp?.default) {
const output = await lib.sharp.default('./image.jpg').resize(width).jpeg({ quality: 80 }).toBuffer()
} else if (lib.image?.Transformer) {
const buf = await readFile('./image.jpg')
const output = await new lib.image.Transformer(buf).resize(width, undefined, 0).jpeg(50)
} else if (lib.jimp?.Jimp) {
const img = await lib.jimp.Jimp.read('./image.jpg')
const output = await img.resize({ w: width }).getBuffer('image/jpeg', { quality: 50 })
}📣 Manajemen Newsletter
sock.newsletterCreate('Nama Channel', 'Deskripsi channel')
sock.newsletterFollow('1231111111111@newsletter')
sock.newsletterUnfollow('1231111111111@newsletter')
sock.newsletterMute('1231111111111@newsletter')
sock.newsletterUnmute('1231111111111@newsletter')
sock.newsletterDelete('1231111111111@newsletter')👥 Manajemen Grup
// Buat grup
const group = await sock.groupCreate('Nama Grup', ['[email protected]'])
// Info grup
const metadata = await sock.groupMetadata(jid)
// Update peserta
sock.groupParticipantsUpdate(jid, ['[email protected]'], 'add') // tambah
sock.groupParticipantsUpdate(jid, ['[email protected]'], 'remove') // keluarkan
sock.groupParticipantsUpdate(jid, ['[email protected]'], 'promote') // jadikan admin
sock.groupParticipantsUpdate(jid, ['[email protected]'], 'demote') // cabut admin
// Pengaturan grup
sock.groupSettingUpdate(jid, 'announcement') // hanya admin yang bisa chat
sock.groupSettingUpdate(jid, 'not_announcement') // semua bisa chat
sock.groupToggleEphemeral(jid, 86400) // aktifkan pesan hilang (86400 = 1 hari)
sock.groupToggleEphemeral(jid, 0) // nonaktifkan pesan hilang
sock.groupLeave(jid)👤 Manajemen Profil
sock.updateProfileName('Nama Saya')
sock.updateProfileStatus('Sedang sibuk')
sock.updateProfilePicture(jid, { url: './photo.jpg' })
sock.removeProfilePicture(jid)
sock.updateBlockStatus(jid, 'block')
sock.updateBlockStatus(jid, 'unblock')
sock.readMessages([message.key])🔐 Manajemen Privasi
sock.updateLastSeenPrivacy('all') // semua bisa lihat last seen
sock.updateLastSeenPrivacy('nobody') // tidak ada yang bisa lihat
sock.updateOnlinePrivacy('all')
sock.updateProfilePicturePrivacy('contacts')
sock.updateReadReceiptsPrivacy('all')
sock.updateReadReceiptsPrivacy('none')
sock.updateGroupsAddPrivacy('contacts')
sock.updateCallPrivacy('everyone')
sock.updateDefaultDisappearingMode(86400)📡 Events
sock.ev.on('connection.update', (update) => {})
sock.ev.on('creds.update', (update) => {})
sock.ev.on('messages.upsert', (update) => {})
sock.ev.on('messages.update', (update) => {})
sock.ev.on('messages.reaction', (update) => {})
sock.ev.on('message-receipt.update', (update) => {})
sock.ev.on('chats.upsert', (update) => {})
sock.ev.on('chats.update', (update) => {})
sock.ev.on('contacts.upsert', (update) => {})
sock.ev.on('contacts.update', (update) => {})
sock.ev.on('groups.upsert', (update) => {})
sock.ev.on('groups.update', (update) => {})
sock.ev.on('group-participants.update', (update) => {})
sock.ev.on('group.join-request', (update) => {})
sock.ev.on('presence.update', (update) => {})
sock.ev.on('lid-mapping.update', (update) => {})
sock.ev.on('blocklist.set', (update) => {})
sock.ev.on('blocklist.update', (update) => {})
sock.ev.on('call', (update) => {})
sock.ev.on('newsletter.reaction', (update) => {})
sock.ev.on('newsletter.view', (update) => {})
sock.ev.on('settings.update', (update) => {})🤖 Rich Response / AI Message
Pesan berformat kaya (AI-style) dengan dukungan code block berwarna, tabel, dan inline link. Dibungkus otomatis dalam botForwardedMessage.
🧾 Code Block
sock.sendMessage(jid, {
code: `function halo() {\n return 'Halo Dunia'\n}`,
language: 'javascript', // opsional, default: 'javascript'
disclaimerText: '⚠️ Kode ini dibuat otomatis'
})📋 Tabel
sock.sendMessage(jid, {
table: [
['Nama', 'Umur', 'Kota'], // baris pertama = heading otomatis
['Alice', '24', 'Jakarta'],
['Bob', '30', 'Surabaya']
],
title: '📋 Data Pengguna'
})🌐 Teks + Inline Link (Kutipan/Referensi)
sock.sendMessage(jid, {
links: [
{
text: 'Baca selengkapnya di sini',
title: 'GitHub Baileys',
url: 'https://github.com/WhiskeySockets/Baileys',
displayName: 'Baileys',
sources: [
{
displayName: 'WhiskeySockets',
subtitle: 'GitHub',
url: 'https://github.com/WhiskeySockets/Baileys'
}
]
}
]
})🧩 Rich Response Gabungan (Array)
sock.sendMessage(jid, {
richResponse: [
{ text: '📝 Penjelasan fungsi di bawah:' },
{
code: [
{ highlightType: 'KEYWORD', codeContent: 'function' },
{ highlightType: 'DEFAULT', codeContent: ' halo() { return ' },
{ highlightType: 'STRING', codeContent: "'Halo'" },
{ highlightType: 'DEFAULT', codeContent: ' }' }
],
language: 'javascript'
},
{
table: [
{ isHeading: true, items: ['Key', 'Value'] },
{ isHeading: false, items: ['name', 'riyoo'] }
],
title: 'Output'
}
],
disclaimerText: '✨ Dibuat otomatis'
})
// Teks & Markdown
await sock.sendMessage(jid, {
richMessage: {
title: 'riyoo',
text: `# Halo Dunia\n## GARA\n\n---\n\n=={ Yellow Text }==\n\n---\n\n[Google](https://google.com)\n\n[](https://openai.com)\n\n[Shiroko|1429|1897]<https://example.com/image.png>`,
}
}, { quoted: m })
// Tip / Metadata Text
await sock.sendMessage(jid, {
richMessage: {
title: 'riyoo',
tip: 'Ini adalah text tip (Metadata Text)',
}
}, { quoted: m })
// Produk
await sock.sendMessage(jid, {
richMessage: {
title: 'riyoo',
product: [
{
title: 'Nama Produk',
brand: 'GARA',
price: 'Rp 1000',
sale_price: 'Rp 0',
url: 'https://wa.me/628xxx',
icon: 'https://example.com/icon.png',
image: 'https://example.com/image.jpg',
}
],
}
}, { quoted: m })
// Code Block
await sock.sendMessage(jid, {
richMessage: {
title: 'riyoo',
code: {
language: 'javascript',
code: `class GARA {\n\tstatic hello() {\n\t\treturn 'Hello World';\n\t}\n}`,
},
}
}, { quoted: m })
// Tabel
await sock.sendMessage(jid, {
richMessage: {
title: 'riyoo',
table: [
['Nama', 'Role'],
['GARA', 'Developer'],
['Fiora Sylvie', 'Assistant'],
],
}
}, { quoted: m })
// Source / Sumber
await sock.sendMessage(jid, {
richMessage: {
title: 'riyoo',
source: [
['https://example.com/favicon.jpg', 'https://github.com/gara31/', 'GitHub'],
['https://example.com/favicon.jpg', 'https://example.com/', 'Website'],
],
}
}, { quoted: m })
// Gambar
await sock.sendMessage(jid, {
richMessage: {
title: 'riyoo',
image: 'https://example.com/image.jpg',
}
}, { quoted: m })
// Video
await sock.sendMessage(jid, {
richMessage: {
title: 'riyoo',
video: 'https://example.com/video.mp4|10', // url|durasi(detik)
}
}, { quoted: m })
// Reels
await sock.sendMessage(jid, {
richMessage: {
title: 'riyoo',
reels: [
{
username: 'GARA',
profile_url: 'https://example.com/avatar.jpg',
thumbnail: 'https://example.com/thumb.jpg',
url: 'https://example.com/',
title: 'Demo Reel',
like: 12000,
share: 500,
view: 999999,
source: 'IG',
verified: true,
}
],
}
}, { quoted: m })
// Post
await sock.sendMessage(jid, {
richMessage: {
title: 'riyoo',
post: [
{
profile_url: 'https://example.com/avatar.jpg',
username: 'GARA',
title: 'Demo Post',
subtitle: 'riyoo',
caption: 'Caption post disini.',
verified: true,
url: 'https://example.com/',
thumbnail: 'https://example.com/thumb.jpg',
source: 'INSTAGRAM',
footer: 'riyoo',
deeplink: 'https://example.com/',
icon: 'https://example.com/icon.jpg',
orientation: 'LANDSCAPE',
post_type: 'PHOTO',
comment: 1,
share: 1,
like: 1,
}
],
}
}, { quoted: m })
// Suggest / Pill
await sock.sendMessage(jid, {
richMessage: {
title: 'riyoo',
suggest: ['GARA', '', 'Fiora Sylvie'],
}
}, { quoted: m })
// Gabungan (video + tip + suggest + text)
await sock.sendMessage(jid, {
richMessage: {
title: 'riyoo',
video: 'https://example.com/video.mp4|10',
tip: 'Ini adalah text tip',
suggest: ['gara', 'riyoo', 'yuuki'],
text: `- [Beli Script](https://wa.me/628xxx)\n- [Sewa Bot](https://wa.me/628xxx)\n- [Support](https://wa.me/628xxx)`,
}
}, { quoted: m })[!NOTE] Rich Response hanya bisa dilihat di WhatsApp terbaru. Tipe
richResponsearray menggunakan token highlight manual (highlightType:KEYWORD,STRING,COMMENT,NUMBER,METHOD,DEFAULT).
📣 Credits
Menggunakan definisi Protocol Buffer yang dikelola oleh WPP Connect via wa-proto.
Kredit penuh diberikan kepada para maintainer dan kontributor asli Baileys:
