@rakku-kun/baileys
v2.0.31
Published
๐ฟ Rakku Baileys - Modern WhatsApp Multi-Device API with enhanced JID/LID mapping & clean architecture.
Downloads
3,774
Maintainers
Readme
โฆ Fitur Utama
Fitur Inti
- โถ Pemetaan
@liddan@jidCerdas - Resolusi konversi otomatis dari LID ke JID secara seamless - โถ Dukungan Multi-Device - Kompatibel penuh dengan protokol WhatsApp multi-device
- โถ Enkripsi End-to-End - Keamanan E2E bawaan untuk menjaga privasi komunikasi
- โถ Semua Jenis Pesan - Mendukung teks, media, polling, reaksi, dll.
- โถ Berbasis TypeScript - Dikembangkan dengan keamanan tipe standar modern
Fitur Lanjutan
- โถ Pengolahan Media - Kirim gambar, video, pesan suara, stiker, hingga dokumen
- โถ Login Kode Pairing - Autentikasi menggunakan kode pairing
"RAKKUWTR" - โถ Dukungan Saluran/Newsletter - Pengelolaan dan interaksi Saluran WhatsApp
- โถ Manajemen Grup - Kontrol penuh untuk administrasi grup
- โถ Pesan Polling & Reaksi - Buat polling interaktif dan deteksi reaksi emoji
๐ฆ Instalasi
npm
npm install @rakku-kun/baileysyarn
yarn add @rakku-kun/baileyspnpm
pnpm add @rakku-kun/baileys๐ Quick Start
Basic Example
import makeWASocket, { DisconnectReason, useMultiFileAuthState } from '@rakku-kun/baileys'
import { Boom } from '@hapi/boom'
async function connectToWhatsApp() {
const { state, saveCreds } = await useMultiFileAuthState('session_rakku')
const sock = makeWASocket({
auth: state,
printQRInTerminal: true
})
sock.ev.on('connection.update', (update) => {
const { connection, lastDisconnect } = update
if (connection === 'close') {
const shouldReconnect = (lastDisconnect?.error as Boom)?.output?.statusCode !== DisconnectReason.loggedOut
if (shouldReconnect) {
connectToWhatsApp()
}
} else if (connection === 'open') {
console.log('โ
Connected to WhatsApp!')
}
})
sock.ev.on('messages.upsert', async ({ messages }) => {
for (const m of messages) {
if (!m.message) continue
console.log('๐ฑ New message:', m.key.remoteJid)
// Reply to message
await sock.sendMessage(m.key.remoteJid!, {
text: 'Hello! I am Rakku Bot ๐ฟ'
})
}
})
sock.ev.on('creds.update', saveCreds)
}
connectToWhatsApp()๐ Authentication
Pairing Code (Recommended)
import makeWASocket from '@rakku-kun/baileys'
const sock = makeWASocket({
printQRInTerminal: false
})
// Request pairing code
if (!sock.authState.creds.registered) {
const phoneNumber = '628xxxxxxxxxx' // Your phone number with country code
const code = await sock.requestPairingCode(phoneNumber, "RAKKUWTR")
console.log('๐ฟ Pairing Code:', code)
}QR Code
import makeWASocket, { Browsers } from '@rakku-kun/baileys'
const sock = makeWASocket({
browser: Browsers.ubuntu('Rakku Bot'),
printQRInTerminal: true
})๐ Common Use Cases
Send Text Message
await sock.sendMessage(jid, { text: 'Hello World! ๐ฟ' })Send Image
await sock.sendMessage(jid, {
image: { url: './image.jpg' },
caption: 'Check this out!'
})Send Video
await sock.sendMessage(jid, {
video: { url: './video.mp4' },
caption: 'Amazing video!',
mimetype: 'video/mp4'
})Send Audio
await sock.sendMessage(jid, {
audio: { url: './audio.mp3' },
mimetype: 'audio/mp4'
})Send Sticker
await sock.sendMessage(jid, {
sticker: { url: './sticker.webp' }
})Send Document
await sock.sendMessage(jid, {
document: { url: './document.pdf' },
mimetype: 'application/pdf',
fileName: 'document.pdf'
})Send Location
await sock.sendMessage(jid, {
location: {
degreesLatitude: -6.2088,
degreesLongitude: 106.8456
}
})Send Contact
const vcard = `BEGIN:VCARD
VERSION:3.0
FN:Rakku Developer
TEL;type=CELL;type=VOICE;waid=6281234567890:+62 812-3456-7890
END:VCARD`
await sock.sendMessage(jid, {
contacts: {
displayName: 'Rakku Developer',
contacts: [{ vcard }]
}
})Send Poll
await sock.sendMessage(jid, {
poll: {
name: 'Favorite Color?',
values: ['Red', 'Blue', 'Green'],
selectableCount: 1
}
})Send Reaction
await sock.sendMessage(jid, {
react: {
text: '๐ฟ',
key: message.key
}
})Reply/Quote Message
await sock.sendMessage(jid, {
text: 'This is a reply'
}, {
quoted: message
})Mention Users
await sock.sendMessage(jid, {
text: 'Hello @6281234567890!',
mentions: ['[email protected]']
})Forward Message
await sock.sendMessage(jid, {
forward: message
})Delete Message (For Everyone)
const msg = await sock.sendMessage(jid, { text: 'test' })
await sock.sendMessage(jid, { delete: msg.key })Edit Message
await sock.sendMessage(jid, {
text: 'Updated text',
edit: message.key
})Pin Message
await sock.sendMessage(jid, {
pin: {
type: 1, // 1=24h, 2=7d, 3=30d
time: 86400,
key: message.key
}
})View Once Message
await sock.sendMessage(jid, {
image: { url: './image.jpg' },
viewOnce: true
})๐ฅ Group Management
Create Group
const group = await sock.groupCreate('My Group', ['[email protected]'])
console.log('Group created:', group.id)Add Participants
await sock.groupParticipantsUpdate(groupId, ['[email protected]'], 'add')Remove Participants
await sock.groupParticipantsUpdate(groupId, ['[email protected]'], 'remove')Promote to Admin
await sock.groupParticipantsUpdate(groupId, ['[email protected]'], 'promote')Demote Admin
await sock.groupParticipantsUpdate(groupId, ['[email protected]'], 'demote')Update Group Name
await sock.groupUpdateSubject(groupId, 'New Group Name')Update Group Description
await sock.groupUpdateDescription(groupId, 'New Description')Get Invite Code
const code = await sock.groupInviteCode(groupId)
const inviteLink = 'https://chat.whatsapp.com/' + codeJoin Group
await sock.groupAcceptInvite('inviteCode')Leave Group
await sock.groupLeave(groupId)๐ Call Handling
Reject Call
sock.ev.on('call', async (calls) => {
for (const call of calls) {
await sock.rejectCall(call.id, call.from)
}
})๐ค User Operations
Check If Number Exists on WhatsApp
const [result] = await sock.onWhatsApp('6281234567890')
if (result?.exists) {
console.log('Number exists:', result.jid)
}Get Profile Picture
// Low resolution
const ppUrl = await sock.profilePictureUrl(jid)
// High resolution
const ppUrl = await sock.profilePictureUrl(jid, 'image')Get Status
const status = await sock.fetchStatus(jid)
console.log('About:', status?.status)Get Business Profile
const profile = await sock.getBusinessProfile(jid)
console.log('Business:', profile)๐ Chat Operations
Archive Chat
const lastMsg = await getLastMessage(jid)
await sock.chatModify({ archive: true, lastMessages: [lastMsg] }, jid)Mute Chat
await sock.chatModify({ mute: 8 * 60 * 60 * 1000 }, jid) // 8 hoursUnmute Chat
await sock.chatModify({ mute: null }, jid)Mark as Read
await sock.readMessages([message.key])Delete Chat
await sock.chatModify({ delete: true, lastMessages: [lastMsg] }, jid)Star Message
await sock.chatModify({
star: {
messages: [{ id: 'messageID', fromMe: true }],
star: true
}
}, jid)Disappearing Messages
// Enable
await sock.sendMessage(jid, {
disappearingMessagesInChat: 7 * 24 * 60 * 60 // 7 days
})
// Disable
await sock.sendMessage(jid, {
disappearingMessagesInChat: false
})๐จ Profile Management
Update Profile Name
await sock.updateProfileName('New Name')Update Profile Status
await sock.updateProfileStatus('New Status ๐ฟ')Update Profile Picture
await sock.updateProfilePicture(jid, { url: './new-pp.jpg' })Remove Profile Picture
await sock.removeProfilePicture(jid)๐ Events
Connection Events
sock.ev.on('connection.update', (update) => {
console.log('Connection:', update)
})Message Events
sock.ev.on('messages.upsert', ({ messages }) => {
console.log('Messages:', messages)
})
sock.ev.on('messages.update', (updates) => {
console.log('Message updates:', updates)
})
sock.ev.on('messages.delete', (deletes) => {
console.log('Messages deleted:', deletes)
})Chat Events
sock.ev.on('chats.upsert', (chats) => {
console.log('New chats:', chats)
})
sock.ev.on('chats.update', (updates) => {
console.log('Chat updates:', updates)
})Contact Events
sock.ev.on('contacts.upsert', (contacts) => {
console.log('New contacts:', contacts)
})
sock.ev.on('contacts.update', (updates) => {
console.log('Contact updates:', updates)
})Group Events
sock.ev.on('groups.upsert', (groups) => {
console.log('New groups:', groups)
})
sock.ev.on('groups.update', (updates) => {
console.log('Group updates:', updates)
})
sock.ev.on('group-participants.update', (update) => {
console.log('Participants update:', update)
})Presence Events
sock.ev.on('presence.update', (presence) => {
console.log('Presence:', presence)
})๐๏ธ Data Store
In-Memory Store
import makeWASocket, { makeInMemoryStore } from '@rakku-kun/baileys'
const store = makeInMemoryStore()
store.readFromFile('./baileys_store.json')
setInterval(() => {
store.writeToFile('./baileys_store.json')
}, 10000)
const sock = makeWASocket()
store.bind(sock.ev)
// Access stored data
console.log('Chats:', store.chats.all())
console.log('Contacts:', store.contacts)
console.log('Messages:', store.messages)๐ง Utilities
JID Helpers
import { jidEncode, jidDecode, isJidGroup, isJidBroadcast } from '@rakku-kun/baileys'
// Encode JID
const jid = jidEncode('6281234567890', 's.whatsapp.net')
// Decode JID
const decoded = jidDecode(jid)
// Check JID type
const isGroup = isJidGroup(jid)
const isBroadcast = isJidBroadcast(jid)Message Helpers
import { getContentType, getDevice, downloadMediaMessage } from '@rakku-kun/baileys'
// Get content type
const type = getContentType(message)
// Get device
const device = getDevice(message)
// Download media
const buffer = await downloadMediaMessage(message, 'buffer')โฆ Komunitas & Dukungan
- โถ Saluran WhatsApp : Klik Disini untuk Bergabung
- โถ Grup WhatsApp : Klik Disini untuk Masuk Grup
- โถ Website Resmi : https://rakkulabs.biz.id
โฆ Penyangkalan (Disclaimer)
Library ini dikembangkan oleh komunitas Rakku Waiter bot. Gunakan dengan bijak dan selalu patuhi Syarat & Ketentuan Layanan WhatsApp.
โฆ Lisensi
Dilisensikan di bawah MIT License.
