Important
This is a custom Baileys build by dcodemaxz, based on WhiskeySockets/Baileys.
This version includes several improvements, enhanced performance, and TypeScript compatibility.
Tip
π₯ This Baileys is intended to support the Vikaru-Bot project
| Feature | Description |
|---|---|
| π¬ Send Messages | Send text, media, documents, and more with rich formatting |
| βοΈ Edit Messages | Edit sent messages after delivery |
| ποΈ Delete Messages | Delete messages from your side or for everyone |
| β€οΈ React Messages | React to messages with emojis (add/remove reactions) |
| π Pin Messages | Pin important messages in chats or groups |
| π Keep Messages | Mark messages as kept/important for later reference |
| π³οΈ Poll Messages | Create and send interactive poll messages |
| π€ AI Message Icon | Add AI-styled icons to bot messages (biz_bot marker) |
| Feature | Description |
|---|---|
| πΌοΈ Send Album Messages | Send grouped media (album style) with captions |
| π¨ Media Utilities | Resize, convert, compress, and sticker creation |
| π Audio Waveform | Automatic waveform generation for audio messages |
| π€ Media Upload | Optimized media upload to WhatsApp servers |
| π₯ Media Download | Download and save media from messages |
| πΌοΈ Full-Size Profile Pictures | Upload HD profile pictures without cropping |
| ποΈ Video to GIF | Convert videos to animated GIFs |
| Feature | Description |
|---|---|
| π Button Messages | Send interactive button messages (quick reply, URL, call) |
| π List Messages | Send single and multi-select list messages |
| π« Interactive Buttons | Quick reply, copy, URL, call, and copy coupon buttons |
| π Single Select | Single selection from categorized item lists |
| Feature | Description |
|---|---|
| π₯ Group Operations | Create, update, leave, and manage groups |
| π€ Member Management | Add, remove, promote, and demote group members |
| π·οΈ Label Group Members | Set labels/tags for individual group members |
| π Group Metadata | Get group info, participants, settings |
| π Group Settings | Configure member add mode, approval mode, ephemeral msgs |
| π’ Group Invites | Generate, revoke, and manage group invite codes/links |
| π₯ JID/LID Support | Full support for @jid and @lid group identifiers |
| π± Ephemeral Messages | Auto-delete messages in groups (24h, 7d, 90d) |
| π Group Status Messages | Send status updates visible only in groups |
| π Event Invitations | Create and send event invitation messages |
| Feature | Description |
|---|---|
| ποΈ Newsletter Operations | Create, follow, unfollow, and manage newsletters |
| π Newsletter Metadata | Get newsletter info, subscribers, verification status |
| π Update Newsletter Info | Change newsletter name, description, and profile picture |
| π€ Newsletter Management | Add/remove admins, change owner, manage subscribers |
| π Admin Count | Get count of newsletter administrators |
| π Mute/Unmute | Mute and unmute newsletter notifications |
| π’ Multiple Newsletter Follow | Follow multiple newsletters at once |
| β€οΈ Newsletter React Messages | React to messages in newsletters |
| Feature | Description |
|---|---|
| π Read Receipts | Send read receipts and mark messages as read |
| β Duplicate Prevention | Prevent duplicate message handling with ID caching |
| π Message Searching | Query and retrieve messages from store |
| π Message Updates | Handle message edits and media retries |
| Feature | Description |
|---|---|
| π Custom Pairing Codes | Generate and use your own pairing codes |
| π οΈ Pairing/QR Fixes | Fixed bugs for WhatsApp linking issues (Pairing/QR) |
| π« Check Banned Numbers | Check if a number is banned on WhatsApp |
| π Privacy Settings | Fetch and manage privacy settings (read receipts, etc) |
| πͺ Logout | Safely logout and end the session |
| βοΈ Multi-file Auth Support | Built-in multi-file auth like official Baileys |
| Feature | Description |
|---|---|
| πΊ Channel Metadata | Get channel info from URLs |
| π Channel ID Checker | Extract channel IDs and metadata from links |
| π’ Status Messages | Send and manage status/story messages |
| Feature | Description |
|---|---|
| π Optimized Performance | Rewritten modules for faster connection and retries |
| π‘ Libsignal Fixes | Latest libsignal-node from WhiskeySockets (clean logs) |
| ποΈ makeInMemoryStore | In-memory store support for message caching |
| π Device Sync (USync) | Latest device protocol with USync query improvements |
| β±οΈ Delay Function | Built-in async delay/sleep function |
| π§ Advanced Handlers | Enhanced message and event handling |
| Feature | Description |
|---|---|
| π Communities Support | Full support for WhatsApp Communities |
| π’ Business Features | Business account and catalog support |
| π‘ Multi-Device (MD) Support | Full multi-device protocol compliance |
| π E2E Encryption | End-to-end encryption with Signal protocol |
Install via package.json:
"dependencies": {
"baileys": "github:dcodemaxz/vikaru-baileys"
}
Install via terminal:
npm install baileys@github:dcodemaxz/vikaru-baileysTip
A simple example of preventing duplicate executions due to duplicate messages from a WhatsApp message ID.
This code caches the first message ID and then automatically ignores messages with the same ID (second, etc.), preventing the bot from executing the command twice. The cache is automatically cleared after reaching 10 IDs to keep it lightweight.
// Duplicate message ( cached )
const duplicateMsg = new Map();
vikaru.ev.on("messages.upsert", ({ messages }) => {
const mek = messages[0]
// Stop execution if the same ID is detected
if (duplicateMsg.has(mek.key.id)) {
console.log(`\nβΊ [ Duplicate-Id ] βΈ ${mek.key.participant || mek.key.remoteJid} | ${mek.key.id}`);
return;
}
// Delete saved id after 10 id
if (duplicateMsg.size >= 10) duplicateMsg.clear();
// Save the incoming id
duplicateMsg.set(mek.key.id, true);
// Command ( case / plugin )
// ...
})Details
// Import variables from baileys
const {
default: makeWASocket,
useMultiFileAuthState,
DisconnectReason,
} = require("baileys");
// Function starts
async function vikarustart() {
const { state, saveCreds } = await useMultiFileAuthState("./session/")
const vikaru = makeWASocket({
auth: state,
browser: ["Ubuntu", "Chrome", "20.0.04"],
getMessage: async (key) => await getMessageFromStore(key),
cachedGroupMetadata: async (jid) => groupCache.get(jid),
});
// ------------------------------------------------------------------- //
// Piring code
if (!vikaru.authState.creds.registered) {
const phoneNumber = "6289508899033"
const customCode = "MAXZBAIL";
const code = await vikaru.requestPairingCode(phoneNumber, customCode);
console.log(`Pairing Code : ${code?.match(/.{1,4}/g)?.join("-") || code}`);
}
// Save credentials after connecting
vikaru.ev.on("creds.update", saveCreds)
// ------------------------------------------------------------------- //
// Detecting connection to server
vikaru.ev.on("connection.update", async (update) => {
const { connection, lastDisconnect } = update;
// Connecting
if (connection == "connecting") {
console.log(`\nβΊ [ Starting Bot ] βΈ Connecting To WhatsApp Server...`);
// Connected
} else if (connection === "open") {
console.log(`\nβΊ [ Connected To ] βΈ ${vikaru.user.id}`);
// Disconnected
} else if (connection === "close") {
const reason = new Boom(lastDisconnect?.error)?.output.statusCode;
if (reason === DisconnectReason.badSession) {
console.log(`\nβΊ [ Disconnected ] βΈ Bad Session File, Please Delete Session and Pairing Again`);
process.exit(1);
} else if (reason === DisconnectReason.connectionClosed) {
console.log(`\nβΊ [ Reconnecting ] βΈ Connection Closed...`);
vikarustart();
} else if (reason === DisconnectReason.connectionLost) {
console.log(`\nβΊ [ Reconnecting ] βΈ Connection Lost From Server...`);
vikarustart();
} else if (reason === DisconnectReason.connectionReplaced) {
console.log(`\nβΊ [ Disconnected ] βΈ Connection Replaced, Another New Session Opened`);
process.exit(1);
} else if (reason === DisconnectReason.loggedOut) {
console.log(`\nβΊ [ Disconnected ] βΈ Device Logged Out, Deleted session Folder and Pairing Again.`);
process.exit(1);
} else if (reason === DisconnectReason.restartRequired) {
console.log(`\nβΊ [ Reconnecting ] βΈ Restarting connection...`);
vikarustart();
} else if (reason === DisconnectReason.timedOut) {
console.log(`\nβΊ [ Reconnecting ] βΈ Connection TimedOut...`);
vikarustart();
} else {
console.log(`\nβΊ [ Disconnected ] βΈ Unknown DisconnectReason: ${reason} | ${connection}`);
process.exit(1);
}
}
});
// ------------------------------------------------------------------- //
// Duplicate message ( cached )
const duplicateMsg = new Set();
// Receive messages
vikaru.ev.on("messages.upsert", ({ messages }) => {
const mek = messages[0]
// Stop execution if the same ID is detected
if (duplicateMsg.has(mek.key.id)) {
console.log(`\nβΊ [ Duplicate-Id ] βΈ ${mek.key.participant || mek.key.remoteJid} | ${mek.key.id}`);
return;
}
// Delete saved id after 10 id
if (duplicateMsg.size >= 10) duplicateMsg.clear();
// Save the incoming id
duplicateMsg.set(mek.key.id, true);
// Simple command
const text = mek.message.conversation
if (text?.startsWith(["/", "#", "!"])) {
const command = text.substring(1).split(" ")[0]
if (command === "ping") {
await vikaru.sendMessage(mek.key.remoteJid,
{ text: "Pong! π" },
{ quoted: mek }
)
}
}
})
// ------------------------------------------------------------------- //
} // end
// Call the start function
vikarustart()Details
await vikaru.edit(message, "Updated message text")
// Or
await vikaru.sendMessage(chatId, {
edit: message.key,
text: "New text content"
})// Delete for yourself
await vikaru.sendMessage(chatId, {
delete: message.key
})
// For groups/newsletter, delete for everyone (admin only)
// Automatically handled based on context// Send read receipt for single message
await vikaru.sendReadReceipt(chatId, participantJid, [messageId], 'read')
// Bulk read messages
await vikaru.readMessages([
{ remoteJid: chatId, id: messageId1 },
{ remoteJid: chatId, id: messageId2 }
])
// Read receipt types: 'read', 'read-self', 'delivery', 'played'// Pin message
await vikaru.sendMessage(chatId, {
pin: message.key
})
// Keep message (mark as important)
await vikaru.sendMessage(chatId, {
keep: message.key
})await vikaru.sendMessage(chatId, {
poll: {
name: "Which feature do you like?",
values: ["Feature A", "Feature B", "Feature C"],
selectableCount: 1
}
})// Resize image
const resized = await vikaru.resize(imageBuffer, 800, 600, { quality: 85 })
// Convert image format
const converted = await vikaru.convert(imageBuffer, { to: '.png' })
// Convert to sticker (512x512 WebP)
const sticker = await vikaru.toSticker(imageBuffer, { quality: 80 })
// Compress video
const compressed = await vikaru.compress(videoBuffer, { quality: 60 })
// Send as sticker pack
await vikaru.sendMessage(chatId, {
stickerPack: {
sticker: await vikaru.toSticker(imageBuffer)
}
})// Send audio with automatic waveform generation
const audioBuffer = fs.readFileSync('./audio.mp3')
await vikaru.sendMessage(chatId, {
audio: audioBuffer,
mimetype: 'audio/mpeg'
// Waveform is automatically generated
})// Simple text message
await vikaru.sendMessage(chatId, { text: "Hello!" })
// With link preview
await vikaru.sendMessage(chatId, {
text: "Check this: https://github.com/dcodemaxz/vikaru-baileys"
})
// Force link preview generation (high quality)
// Configure: generateHighQualityLinkPreview: true in socket configawait vikaru.sendMessage(chatId, {
title: "β *`EXAMPLE BUTTONS`*",
text: "Choose one of the options below:",
footer: "Β© dcodemaxz baileys",
// image: { url: "https://example.com/image.jpg" },
interactiveButtons: [
// Reply button
{
name: "quick_reply",
buttonParamsJson: JSON.stringify({
display_text: "Quick Reply",
id: "reply_id_1"
})
},
// Copy button (copy to clipboard)
{
name: "quick_copy",
buttonParamsJson: JSON.stringify({
display_text: "Copy Code",
id: "copy_id_1",
copy_code: "VIKARU-2025"
})
},
// URL button
{
name: "cta_url",
buttonParamsJson: JSON.stringify({
display_text: "Visit Website",
url: "https://github.com/dcodemaxz"
})
},
// Call button
{
name: "cta_call",
buttonParamsJson: JSON.stringify({
display_text: "Call Support",
phone_number: "+6289508899033"
})
}
]
}, { quoted: null })// Single select list
await vikaru.sendMessage(chatId, {
title: "β *`SELECT ITEMS`*",
text: "Choose one of the following:",
footer: "Β© dcodemaxz baileys",
interactiveButtons: [
{
name: "single_select",
buttonParamsJson: JSON.stringify({
title: "Choose Product",
sections: [
{
title: "ποΈ Category 1",
highlight_label: "Recommended",
rows: [
{
header: "Product A",
title: "Buy Product A",
description: "High quality product",
id: "buy_a"
},
{
header: "Product B",
title: "Buy Product B",
description: "Budget friendly",
id: "buy_b"
}
]
},
{
title: "π Category 2",
rows: [
{
header: "Product C",
title: "Buy Product C",
description: "Premium option",
id: "buy_c"
}
]
}
]
})
}
]
}, { quoted: null })await vikaru.sendMessage(chatId, {
album: [
{ image: { url: "https://example.com/image1.jpg" } },
{ image: { url: "https://example.com/image2.jpg" } },
{ video: { url: "https://example.com/video.mp4" } },
{ image: { url: "https://example.com/image3.jpg" } }
],
caption: "Beautiful album collection π¨"
})// React with emoji
await vikaru.react(message, "π₯")
// Or
await vikaru.sendMessage(chatId, {
react: {
text: "π",
key: message.key
}
})
// Remove reaction
await vikaru.unreact(message)// Reply/Quote to a message
await vikaru.sendMessage(chatId, {
text: "This is a reply!"
}, {
quoted: message // or message.key
})// Add AI bot icon to message
await vikaru.sendMessage(chatId, {
text: "This message is from AI Bot! π€",
ai: true // Displays AI icon
})// Create newsletter
const newsletter = await vikaru.newsletterCreate(
"My Newsletter",
"Latest updates and news",
fs.readFileSync('./newsletter-pic.jpg')
)
// Follow newsletter
await vikaru.newsletterFollow("123456789@newsletter")
// Unfollow newsletter
await vikaru.newsletterUnfollow("123456789@newsletter")
// Update newsletter name
await vikaru.newsletterUpdateName("123456789@newsletter", "Updated Name")
// Update description
await vikaru.newsletterUpdateDescription("123456789@newsletter", "New description here")
// Update profile picture
await vikaru.newsletterUpdatePicture("123456789@newsletter", fs.readFileSync('./pic.jpg'))
// Remove profile picture
await vikaru.newsletterRemovePicture("123456789@newsletter")
// Mute/Unmute newsletters
await vikaru.newsletterMute("123456789@newsletter")
await vikaru.newsletterUnmute("123456789@newsletter")
// Change newsletter owner
await vikaru.newsletterChangeOwner("123456789@newsletter", "1234567890@s.whatsapp.net")
// Demote admin
await vikaru.newsletterDemote("123456789@newsletter", "1234567890@s.whatsapp.net")
// Delete newsletter
await vikaru.newsletterDelete("123456789@newsletter")
// Get admin count
const adminCount = await vikaru.newsletterAdminCount("123456789@newsletter")
// React to newsletter message
await vikaru.newsletterReactMessage("123456789@newsletter", "175", "π₯³")
// Get newsletter metadata
const metadata = await vikaru.newsletterMetadata("invite", "code_here")
// Subscribe to newsletter live updates
await vikaru.subscribeNewsletterUpdates("123456789@newsletter")// Create group
const group = await vikaru.groupCreate("My Group", ["628xx@s.whatsapp.net", "628yy@s.whatsapp.net"])
// Get group metadata
const metadata = await vikaru.groupMetadata(groupJid)
// Update group name
await vikaru.groupUpdateSubject(groupJid, "New Group Name")
// Update group description
await vikaru.groupUpdateDescription(groupJid, "Group description here")
// Add member(s)
await vikaru.groupParticipantsUpdate(groupJid, ["628xx@s.whatsapp.net"], "add")
// Remove member(s)
await vikaru.groupParticipantsUpdate(groupJid, ["628xx@s.whatsapp.net"], "remove")
// Promote to admin
await vikaru.groupParticipantsUpdate(groupJid, ["628xx@s.whatsapp.net"], "promote")
// Demote admin
await vikaru.groupParticipantsUpdate(groupJid, ["628xx@s.whatsapp.net"], "demote")
// Leave group
await vikaru.groupLeave(groupJid)
// Get group invite code
const inviteCode = await vikaru.groupInviteCode(groupJid)
// Revoke invite
await vikaru.groupRevokeInvite(groupJid)
// Accept group invite
const joinedGroup = await vikaru.groupAcceptInvite("inviteCodeHere")
// Get invite info
const inviteInfo = await vikaru.groupGetInviteInfo("inviteCodeHere")
// Set label for group member
await vikaru.setLabelGroup(groupJid, "VIP Members")
// Toggle ephemeral messages (auto-delete)
await vikaru.groupToggleEphemeral(groupJid, 604800) // 7 days
// Update group settings
await vikaru.groupSettingUpdate(groupJid, "announcement") // announcement only
// Set member add mode
await vikaru.groupMemberAddMode(groupJid, [{ tag: "member_add_mode", attrs: {}, content: "restricted" }])
// Set join approval mode
await vikaru.groupJoinApprovalMode(groupJid, "on")// Send status message visible to group
await vikaru.sendStatusMention({
text: "Group update! Check this out π’"
}, [groupJid])// Check channel/newsletter from URL
const channelInfo = await vikaru.cekIDSaluran("https://whatsapp.com/channel/xxxx")
console.log(channelInfo)
// Returns: { name, id, state, subscribers, verification, creation_time }// Check if number is banned
const isBanned = await vikaru.checkBanned("6289508899033@s.whatsapp.net")
if (isBanned) {
console.log("This number is banned on WhatsApp")
}// Delay for 5 seconds
await vikaru.delay(5)
// Delay for 2.5 seconds
await vikaru.delay(2.5)// Request pairing code
const phoneNumber = "6289508899033"
const customCode = "MAXZBAIL" // Optional custom code
const code = await vikaru.requestPairingCode(phoneNumber, customCode)
console.log(`Your Pairing Code: ${code?.match(/.{1,4}/g)?.join("-") || code}`)// Logout and end session
await vikaru.logout("Goodbye!")// Retry and update media message (if media failed)
const updatedMessage = await vikaru.updateMediaMessage(message)// Get your privacy settings
const privacySettings = await vikaru.fetchPrivacySettings()
// Returns: { readreceipts, lastseen, onlineStatus, profilePhoto, ... }const { makeWASocket, makeInMemoryStore } = require('baileys')
const store = makeInMemoryStore({
logger: pino({ level: 'debug' })
})
const vikaru = makeWASocket({ auth: state })
store.bind(vikaru.ev)
// Now you can access messages from store
console.log(store.messages[chatId])
console.log(store.contacts[jid])
console.log(store.chats)// Connection updates
vikaru.ev.on('connection.update', (update) => {
const { connection, lastDisconnect, isNewLogin } = update
console.log(connection, lastDisconnect, isNewLogin)
})
// Messages
vikaru.ev.on('messages.upsert', ({ messages, type }) => {
console.log(`Messages: ${type}`, messages)
})
// Message updates
vikaru.ev.on('messages.update', (updates) => {
console.log('Message updates:', updates)
})
// Chats
vikaru.ev.on('chats.upsert', (chats) => {
console.log('Chats upserted:', chats)
})
// Groups
vikaru.ev.on('groups.update', (updates) => {
console.log('Groups updated:', updates)
})
// Contacts
vikaru.ev.on('contacts.upsert', (contacts) => {
console.log('Contacts upserted:', contacts)
})
// Credentials
vikaru.ev.on('creds.update', saveCreds)Note
If you find a bug or need help, please open an issue.
Caution
This project is not affiliated with WhatsApp Inc.
Use it responsibly. Avoid spam, abuse, or illegal activity.
β‘ Thanks to
- whiskeysockets
- baileys-mod
- whileys
MIT Β© 2025 dcodemaxz
