{"_id":"@dhikzx/baileys","_rev":"3-4d3614dd57c9686ff40ca9130091ee9d","name":"@dhikzx/baileys","dist-tags":{"latest":"2.0.1"},"versions":{"1.0.0":{"name":"@dhikzx/baileys","version":"1.0.0","license":"MIT","_id":"@dhikzx/baileys@1.0.0","maintainers":[{"name":"dhikzx","email":"dikzzgans424@gmail.com"}],"dist":{"shasum":"eace0ce0eaddd24a3be2c7ece51e72d3a445e886","tarball":"https://registry.npmjs.org/@dhikzx/baileys/-/baileys-1.0.0.tgz","fileCount":297,"integrity":"sha512-MZvIyuS/3aqcfPMIzKrQQyDpiJ2nUbafmNrmIs1WpjR8fMKYVoojJ4MLt+ckoyAS3RHOfOBCARqakV2qxKLsMQ==","signatures":[{"sig":"MEUCIF7r7S+cpM2PCHBNa4tjkLsmLwssutYMT0FaHHvvk3V2AiEAx6kr5yUNzTl3CBWIm1vraKuRPDxVqfavTTs0magUZvw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":63957531},"main":"index.js","type":"commonjs","_npmUser":{"name":"dhikzx","email":"dikzzgans424@gmail.com"},"_npmVersion":"10.9.7","description":"Custom Baileys by DhikzxCloud","directories":{},"_nodeVersion":"21.7.3","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/baileys_1.0.0_1774542018186_0.9718976869449742","host":"s3://npm-registry-packages-npm-production"}},"1.9.2":{"name":"@dhikzx/baileys","version":"1.9.2","license":"MIT","_id":"@dhikzx/baileys@1.9.2","maintainers":[{"name":"dhikzx","email":"dikzzgans424@gmail.com"}],"dist":{"shasum":"817c63e82c69bc675fe6e02f209095ec2bfd3cd3","tarball":"https://registry.npmjs.org/@dhikzx/baileys/-/baileys-1.9.2.tgz","fileCount":290,"integrity":"sha512-XQsmXTTiT6YtRJ8rlw3qDU9Bna0jid4FQjGz59sbesS2nl2RhZDsEk2oJapI3ZgKReQT7H7CLGWZ8g4+TwcUsA==","signatures":[{"sig":"MEUCIHs2TeeAVRlO4nDTHp1XN57uDZMDc22Xd9Q88sloB0d2AiEAjfUOJJpJYhP0MhAHmvb3BaEbxtaL14gPnKMC0cN2thE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":41465264},"main":"index.js","type":"commonjs","_npmUser":{"name":"dhikzx","email":"dikzzgans424@gmail.com"},"_npmVersion":"10.9.7","description":"Custom Baileys by DhikzxCloud","directories":{},"_nodeVersion":"21.7.3","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/baileys_1.9.2_1774543311922_0.07099231956503504","host":"s3://npm-registry-packages-npm-production"}},"2.0.1":{"name":"@dhikzx/baileys","version":"2.0.1","description":"WhatsApp API by Dhikzx","keywords":["baileys","baileys-mod","bails","whiskeysockets/baileys","whatsapp","meta","Hydra","Kelvdra","whatsapp","js-whatsapp","whatsapp-api","whatsapp-web","whatsapp-chat","whatsapp-group","automation","multi-device","modder"],"homepage":"https://github.com/WhiskeySockets/Baileys/","repository":{"url":"git+ssh://git@github.com/WhiskeySockets/Baileys.git"},"license":"MIT","author":{"name":"Kelvdra"},"main":"lib/index.js","types":"lib/index.d.ts","scripts":{"test":"jest"},"dependencies":{"@hapi/boom":"^9.1.3","@adiwajshing/keyed-db":"^0.2.4","@cacheable/node-cache":"1.5.3","@whiskeysockets/eslint-config":"^1.0.0","async-mutex":"^0.5.0","axios":"^1.12.1","audio-decode":"^2.2.2","cache-manager":"^5.7.6","chalk":"^4.1.2","fflate":"^0.8.2","lodash":"^4.17.21","libsignal":"npm:@meta.inc/libsignal@*","link-preview-js":"^3.0.14","lru-cache":"^11.1.0","music-metadata":"^7.12.3","pino":"^9.6","protobufjs":"^7.2.4","qrcode-terminal":"^0.12.0","ws":"^8.13.0"},"devDependencies":{"@types/jest":"^29.5.14","@types/node":"^16.0.0","@types/ws":"^8.0.0","conventional-changelog-cli":"^2.2.2","eslint":"^8.0.0","jest":"^30.1.1","jimp":"^0.22.12","json":"^11.0.0","link-preview-js":"^3.0.5","open":"^8.4.2","release-it":"^15.10.3","ts-jest":"^29.4.1","ts-node":"^10.8.1","typedoc":"^0.27.9","typedoc-plugin-markdown":"4.4.2","typescript":"^5.8.2"},"peerDependencies":{"jimp":"^0.22.12"},"peerDependenciesMeta":{"jimp":{"optional":true}},"packageManager":"yarn@1.22.19","engines":{"node":">=20.0.0"},"directories":{"lib":"lib"},"_id":"@dhikzx/baileys@2.0.1","bugs":{"url":"https://github.com/WhiskeySockets/Baileys/issues"},"_nodeVersion":"21.7.3","_npmVersion":"10.9.7","dist":{"integrity":"sha512-xSbZrHcDjVosS+xSspQDtxHwmjTu8W4VljHV0RbkgKuK367MYP1Bmtemp+D5AIfCl4bXBZkXJKfQJpHj0pWAZQ==","shasum":"d4b2dd68557cba4adeaa3880ed18e7d8270890b0","tarball":"https://registry.npmjs.org/@dhikzx/baileys/-/baileys-2.0.1.tgz","fileCount":284,"unpackedSize":41417204,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIF730evzh6ygLE9jfnquOzKt1xG6F7oYoDGPifmZv05tAiAY8gqZ6yzOTEpmXOTX2tBuGoiyV0K2b+kOex9XiSxiWw=="}]},"_npmUser":{"name":"dhikzx","email":"dikzzgans424@gmail.com"},"maintainers":[{"name":"dhikzx","email":"dikzzgans424@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/baileys_2.0.1_1774544708892_0.8966311650811745"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-26T16:20:18.068Z","modified":"2026-03-26T17:05:09.324Z","1.0.0":"2026-03-26T16:20:18.982Z","1.9.2":"2026-03-26T16:41:52.271Z","2.0.1":"2026-03-26T17:05:09.226Z"},"license":"MIT","description":"WhatsApp API by Dhikzx","maintainers":[{"name":"dhikzx","email":"dikzzgans424@gmail.com"}],"readme":"<!-- PROJECT HEADER -->\n<div align=\"center\">\n  <img src=\"https://c.termai.cc/i135/VVcxoyz.jpeg\" alt=\"WhatsApp Web API\" width=\"600\"/>\n\n  # WhatsApp Web API\n  **Advanced Baileys WhatsApp API Wrapper**\n\n  [![NPM Version](https://img.shields.io/npm/v/@dhikzx/baileys?color=brightgreen&label=NPM)](https://www.npmjs.com/package/@dhikzx/baileys)\n  [![Downloads](https://img.shields.io/npm/dw/@dhikzx/baileys?color=blue&label=Downloads)](https://www.npmjs.com/package/@dhikzx/baileys)\n  [![License](https://img.shields.io/github/license/dhikzx/baileys?color=yellow)](./LICENSE)\n\n  ---\n  A modern and feature-rich WhatsApp Web API built on top of **Baileys** — \n  designed for automation, chatbots, and integration with any Node.js project.\n</div>\n\n---\n\n## 📑 Table of Contents\n- [⚡ Quick Start](#-quick-start)\n- [📦 Installation](#-installation)\n- [🔌 Connecting Account](#-connecting-account)\n- [💡 Important Notes](#-important-notes-about-socket-config)\n- [💾 Saving & Restoring Sessions](#-saving--restoring-sessions)\n- [📡 Handling Events](#-handling-events)\n- [🛠 Implementing a Data Store](#-implementing-a-data-store)\n- [🔑 WhatsApp IDs](#-whatsapp-ids-explain)\n- [✉️ Sending Messages](#-sending-messages)\n    - [Non-Media Messages](#non-media-messages)\n        - [Text Message](#text-message)\n        - [Quote Message](#quote-message-works-with-all-types)\n        - [Mention User](#mention-user-works-with-most-types)\n        - [Mention Status](#mention-status)\n        - [Result Poll From Newsletter](#result-poll-from-newsletter)\n        - [SendAlbumMessage](#send-album-message)\n        - [SendMessage Product Simple](#SendMessage-Product-Simple)\n        - [SendMessage Carousel](#sendMessage-Carousel)\n        - [Request Payment](#request-payment)\n        - [Event Message](#event-message)\n        - [Interactive Message with Native Flow](#Interactive-Message-with-Native-Flow)\n        - [Interactive](#interactive)\n        - [Forward Messages](#forward-messages)\n        - [Location Message](#location-message)\n        - [Contact Message](#contact-message)\n        - [Reaction Message](#reaction-message)\n        - [Pin Message](#pin-message)\n        - [Keep Message](#keep-message)\n        - [Poll Message](#poll-message)\n    - [Sending with Link Preview](#sending-messages-with-link-previews)\n- [🖼 Media Messages](#-media-messages)\n    - [Gif Message](#gif-message)\n        - [Video Message](#video-message)\n        - [Audio Message](#audio-message)\n        - [Image Message](#image-message)\n        - [ViewOnce Message](#view-once-message)\n- [✏️ Modify Messages](#-modify-messages)\n- [📥 Downloading & Re-uploading Media](#-manipulating-media-messages)\n- [📞 Call & Presence Handling](#-reject-call)\n- [💬 Chat Modifications](#-modifying-chats)\n- [🔍 User Queries](#-user-querys)\n- [👤 Profile Management](#-change-profile)\n- [👥 Group Management](#-groups)\n- [🔒 Privacy Controls](#-privacy)\n- [📢 Broadcast & Stories](#-broadcast-lists--stories)\n- [🧩 Custom Functionality](#-writing-custom-functionality)\n\n---\n\n## ⚡ Quick Start\n\nExample usage:\n\n```bash\ncd path/to/Baileys\nnpm install\nnode example.js\n```\n\nOr check the **[example.ts](Example/example.ts)** for a TypeScript version.\n\n---\n\n## 📦 Installation\n\n**Stable version**\n```bash\nnpm install @dhikzx/baileys\n```\n\n**Edge version** (latest features, may be unstable)\n```bash\nyarn add @dhikzx/baileys@latest\n```\n\n**Import into your code**\n```javascript\nconst { default: makeWASocket } = require(\"@dhikzx/baileys\")\n```\n\n> ⚠️ **Tip:** Use the stable version for production environments.\n\n---\n\n## 🔌 Connecting Account\n\nWhatsApp supports **multi-device API**, allowing Baileys to act as a secondary WhatsApp Web client.  \nYou can connect via **QR Code** or **Pairing Code**.\n\n# How To Connect To Whatsapp\n## With QR Code\n```javascript\nconst {\n  default: makeWASocket\n} = require('@dhikzx/baileys');\n\nconst client = makeWASocket({\n  browser: ['Ubuntu', 'Chrome', '20.00.1'],\n  printQRInTerminal: true\n})\n```\n\n## Connect With Number\n```javascript\nconst {\n  default: makeWASocket,\n  fetchLatestWAWebVersion\n} = require('@dhikzx/baileys');\n\nconst client = makeWASocket({\n  browser: ['Ubuntu', 'Chrome', '20.00.1'],\n  printQRInTerminal: false,\n  version: fetchLatestWAWebVersion()\n  // Other options\n});\n\nconst number = \"628XXXXX\";\nconst code = await client.requestPairingCode(number.trim) /* Use : (number, \"YYYYYYYY\") for custom-pairing */\n\nconsole.log(\"Ur pairing code : \" + code)\n```\n\n## 💡 Important Notes About Socket Config\n\n### 📌 Cache Group Metadata\n```javascript\nconst groupCache = new NodeCache({ stdTTL: 5 * 60, useClones: false });\n\nconst sock = makeWASocket({\n    cachedGroupMetadata: async (jid) => groupCache.get(jid)\n});\n```\n\n### 🔄 Improve Retry & Poll Decryption\n```javascript\nconst sock = makeWASocket({\n    getMessage: async (key) => await getMessageFromStore(key)\n});\n```\n\n### 📱 Receive Notifications in WhatsApp App\n```javascript\nconst sock = makeWASocket({\n    markOnlineOnConnect: false\n});\n```\n\n---\n\n## 💾 Saving & Restoring Sessions\n\nAvoid scanning QR every time:\n```javascript\nconst makeWASocket = require(\"@dhikzx/baileys\").default;\nconst { useMultiFileAuthState } = require(\"@dhikzx/baileys\");\n\nconst { state, saveCreds } = await useMultiFileAuthState('auth_info_baileys');\nconst sock = makeWASocket({ auth: state });\n\nsock.ev.on('creds.update', saveCreds);\n```\n> 💡 Recommended to store auth in a database for production.\n\n---\n\n## 📡 Handling Events\n\nListen to events using:\n```javascript\nsock.ev.on('messages.upsert', ({ messages }) => {\n    console.log('got messages', messages);\n});\n```\n\n### Example to Start\n\n> [!NOTE]\n> This example includes basic auth storage too\n\n```javascript\nconst makeWASocket = require(\"@dhikzx/baileys\").default;\nconst { DisconnectReason, useMultiFileAuthState } = require(\"@dhikzx/baileys\");\nconst Boom = require('@hapi/boom');\n\nasync function connectToWhatsApp () {\n    const { state, saveCreds } = await useMultiFileAuthState('auth_info_baileys')\n    const sock = makeWASocket({\n        // can provide additional config here\n        auth: state,\n        printQRInTerminal: true\n    })\n    sock.ev.on('connection.update', (update) => {\n        const { connection, lastDisconnect } = update\n        if(connection === 'close') {\n            const shouldReconnect = (lastDisconnect.error as Boom)?.output?.statusCode !== DisconnectReason.loggedOut\n            console.log('connection closed due to ', lastDisconnect.error, ', reconnecting ', shouldReconnect)\n            // reconnect if not logged out\n            if(shouldReconnect) {\n                connectToWhatsApp()\n            }\n        } else if(connection === 'open') {\n            console.log('opened connection')\n        }\n    })\n    sock.ev.on('messages.upsert', event => {\n        for (const m of event.messages) {\n            console.log(JSON.stringify(m, undefined, 2))\n\n            console.log('replying to', m.key.remoteJid)\n            await sock.sendMessage(m.key.remoteJid!, { text: 'Hello Word' })\n        }\n    })\n\n    // to storage creds (session info) when it updates\n    sock.ev.on('creds.update', saveCreds)\n}\n// run in main file\nconnectToWhatsApp()\n```\n\n> [!IMPORTANT]\n> In `messages.upsert` it's recommended to use a loop like `for (const message of event.messages)` to handle all messages in array\n\n### Decrypt Poll Votes\n\n- By default poll votes are encrypted and handled in `messages.update`\n- That's a simple example\n```javascript\nsock.ev.on('messages.update', event => {\n    for(const { key, update } of event) {\n        if(update.pollUpdates) {\n            const pollCreation = await getMessage(key)\n            if(pollCreation) {\n                console.log(\n                    'got poll update, aggregation: ',\n                    getAggregateVotesInPollMessage({\n                        message: pollCreation,\n                        pollUpdates: update.pollUpdates,\n                    })\n                )\n            }\n        }\n    }\n})\n```\n\n- `getMessage` is a [store](#implementing-a-data-store) implementation (in your end)\n\n### Summary of Events on First Connection\n\n1. When you connect first time, `connection.update` will be fired requesting you to restart sock\n2. Then, history messages will be received in `messaging.history-set`\n\n## Implementing a Data Store\n\n- Baileys does not come with a defacto storage for chats, contacts, or messages. However, a simple in-memory implementation has been provided. The store listens for chat updates, new messages, message updates, etc., to always have an up-to-date version of the data.\n\n> [!IMPORTANT]\n> I highly recommend building your own data store, as storing someone's entire chat history in memory is a terrible waste of RAM.\n\nIt can be used as follows:\n\n```javascript\nconst makeWASocket = require(\"@dhikzx/baileys\").default;\nconst { makeInMemoryStore } = require(\"@dhikzx/baileys\");\n// the store maintains the data of the WA connection in memory\n// can be written out to a file & read from it\nconst store = makeInMemoryStore({ })\n// can be read from a file\nstore.readFromFile('./baileys_store.json')\n// saves the state to a file every 10s\nsetInterval(() => {\n    store.writeToFile('./baileys_store.json')\n}, 10_000)\n\nconst sock = makeWASocket({ })\n// will listen from this socket\n// the store can listen from a new socket once the current socket outlives its lifetime\nstore.bind(sock.ev)\n\nsock.ev.on('chats.upsert', () => {\n    // can use 'store.chats' however you want, even after the socket dies out\n    // 'chats' => a KeyedDB instance\n    console.log('got chats', store.chats.all())\n})\n\nsock.ev.on('contacts.upsert', () => {\n    console.log('got contacts', Object.values(store.contacts))\n})\n\n```\n\nThe store also provides some simple functions such as `loadMessages` that utilize the store to speed up data retrieval.\n\n## Whatsapp IDs Explain\n\n- `id` is the WhatsApp ID, called `jid` too, of the person or group you're sending the message to.\n    - It must be in the format ```[country code][phone number]@s.whatsapp.net```\n            - Example for people: ```+19999999999@s.whatsapp.net```.\n            - For groups, it must be in the format ``` 123456789-123345@g.us ```.\n    - For broadcast lists, it's `[timestamp of creation]@broadcast`.\n    - For stories, the ID is `status@broadcast`.\n\n## Utility Functions\n\n- `getContentType`, returns the content type for any message\n- `getDevice`, returns the device from message\n- `makeCacheableSignalKeyStore`, make auth store more fast\n- `downloadContentFromMessage`, download content from any message\n\n## Sending Messages\n\n- Send all types of messages with a single function\n    - **[Here](https://baileys.whiskeysockets.io/types/AnyMessageContent.html) you can see all message contents supported, like text message**\n    - **[Here](https://baileys.whiskeysockets.io/types/MiscMessageGenerationOptions.html) you can see all options supported, like quote message**\n\n    ```javascript\n    const jid: string\n    const content: AnyMessageContent\n    const options: MiscMessageGenerationOptions\n\n    sock.sendMessage(jid, content, options)\n    ```\n\n### Non-Media Messages\n\n\n#### Text Message\n```javascript\nawait sock.sendMessage(jid, { text: 'hello word' })\n```\n\n#### Quote Message (works with all types)\n```javascript\nawait sock.sendMessage(jid, { text: 'hello word' }, { quoted: message })\n```\n\n#### Mention User (works with most types)\n- @number is to mention in text, it's optional\n```javascript\nawait sock.sendMessage(\n    jid,\n    {\n        text: '@12345678901',\n        mentions: ['12345678901@s.whatsapp.net']\n    }\n)\n```\n\n#### Mention Status\n- [ jid ] If the Jid Group and Jid Private Chat are included in the JID list, try to make the JID group first starting from the Jid Private Chat or Jid Private Chat in the middle between the group Jid\n```javascript\nawait sock.sendStatusMentions(\n     {\n        text: \"Hello\", // or image / video / audio ( url or buffer )\n     },\n     [\n      \"123456789123456789@g.us\",\n      \"123456789@s.whatsapp.net\",\n      // Enter jid chat here\n     ] \n)  \n```\n\n#### Result Poll From Newsletter\n```javascript\nawait sock.sendMessage(\n    jid,\n    {\n        pollResult: {\n            name: \"Text poll\",\n            votes: [[\"Options 1\", 10], [\"Options 2\", 10]], // 10 For Fake Polling Count Results\n        }\n    }, { quoted : message }\n)\n```\n\n#### Send Album Message\n- url or buffer ( image or video ) \n```javascript\nawait sock.sendAlbumMessage(\n    jid,\n    [\n       {\n          image: { url: \"https://example.jpg\" }, // or buffer\n          caption: \"Hello World\",\n       },\n       {\n          video: { url: \"https://example.mp4\" }, // or buffer\n          caption: \"Hello World\",\n       },\n    ],\n    { \n       quoted : message, \n       delay : 2000 // number in seconds\n    }\n)\n\n```\n\n#### Request Payment\n```javascript\n- Example non media sticker\nawait sock.sendMessage(\n    jid,\n    {\n        requestPayment: {      \n           currency: \"IDR\",\n           amount: \"10000000\",\n           from: \"123456@s.whatsapp.net\",\n           note: \"Hai Guys\",\n           background: { ...background of the message }\n        }\n    },\n    { quoted : message }\n)\n\n- with media sticker buffer\nawait sock.sendMessage(\n    jid,\n    {\n        requestPayment: {      \n           currency: \"IDR\",\n           amount: \"10000000\",\n           from: \"123456@s.whatsapp.net\",\n           sticker: Buffer,\n           background: { ...background of the message }\n        }\n    },\n    { quoted : message }\n)\n\n- with media sticker url\nawait sock.sendMessage(\n    jid,\n    {\n        requestPayment: {      \n           currency: \"IDR\",\n           amount: \"10000000\",\n           from: \"123456@s.whatsapp.net\",\n           sticker: { url: Sticker Url },\n           background: { ...background of the message }\n        }\n    },\n    { quoted : message }\n)\n```\n\n#### Event Message\n```javascript\nawait sock.sendMessage(\n   jid, \n   { \n       event: {\n           isCanceled: false, // or true for cancel event \n           name: \"Name Event\", \n           description: \"Description Event\",\n           location: { \n               degressLatitude: -0, \n               degressLongitude: - 0 \n           },\n           link: Call Link,\n           startTime: m.messageTimestamp.low,\n           endTime: m.messageTimestamp.low + 86400, // 86400 is day in seconds\n           extraGuestsAllowed: true // or false\n       }\n   },\n   { quoted : message }\n)\n```\n\n### SendMessage Product Simple\n```javascript\nconn.sendMessage(m.chat, {\n                    productMessage: {\n                        title: \"tes\",\n                        description: \"penis\",\n                        thumbnail: \"https://example.png\",\n                        productId: \"123456789\",\n                        retailerId: \"TOKOKU\",\n                        url: \"https://example.png\",\n                        body: \"penis\",\n                        footer: \"wabot\",\n                        buttons: [\n                            {\n                                name: \"cta_url\",\n                                buttonParamsJson: JSON.stringify({\n                                    display_text: \"K\",\n                                    url: \"google.com\"\n                                })\n                            }\n                        ]\n                    }\n                }, { quoted: m });\n```\n### SendMessage Carousel\n```javascript\nawait sock.sendMessage(\n    jid,\n    {\n        carouselMessage: {\n            caption: \"Klik Url\",\n            footer: \"Powered By Hydra\",\n            cards: [\n                // ✅ Card Mode Product\n                {\n                    headerTitle: \"`</> Owner Bot </>`\",\n                    imageUrl: logo.thumb,\n                    productTitle: \"Premium Bot\",\n                    productDescription: \"Dapatkan akses premium\",\n                    bodyText: \"[Hydra]\\n- Chat yang penting aja\\n- Jangan telpon owner\",\n                    buttons: [\n                        {\n                            name: \"cta_call\",\n                            params: { display_text: \"Contact Owner\", phone_number: \"+6287784901856\" }\n                        }\n                    ]\n                },\n                // ✅ Card Mode Gambar Biasa\n                {\n                    headerTitle: \"`</> Bot Elaina </>`\",\n                    imageUrl: logo.thumb,\n                    bodyText: \"[Elaina AI]\\n- Jangan spam bot\\n- Jangan telpon bot\",\n                    buttons: [\n                        {\n                            name: \"cta_url\",\n                            params: {\n                                display_text: \"Chat Bot\",\n                                url: \"https://wa.me/6281918402014\",\n                                merchant_url: \"https://wa.me/6281918402014\"\n                            }\n                        }\n                    ]\n                }\n            ]\n        }\n    },\n    { quoted: m },\n    conn\n);\n```\n\n### Interactive Message with Native Flow\nSend interactive messages with buttons, copy actions, and native flow features:\n\n```javascript\nawait sock.sendMessage(jid, {    \n    interactiveMessage: {      \n        title: \"Hello World\",      \n        footer: \"telegram: @draa82\",      \n        image: { url: \"https://example.com/image.jpg\" },      \n        nativeFlowMessage: {        \n            messageParamsJson: JSON.stringify({          \n                limited_time_offer: {            \n                    text: \"idk hummmm?\",            \n                    url: \"t.me/draa82\",            \n                    copy_code: \"dhikzx 1437\",            \n                    expiration_time: Date.now() * 999          \n                },          \n                bottom_sheet: {            \n                    in_thread_buttons_limit: 2,            \n                    divider_indices: [1, 2, 3, 4, 5, 999],            \n                    list_title: \"dhikzx\",            \n                    button_title: \"dhikzx\"          \n                },          \n                tap_target_configuration: {            \n                    title: \" X \",            \n                    description: \"bomboclard\",            \n                    canonical_url: \"https://t.me/draa82\",            \n                    domain: \"shop.example.com\",            \n                    button_index: 0          \n                }        \n            }),        \n            buttons: [          \n                {            \n                    name: \"single_select\",            \n                    buttonParamsJson: JSON.stringify({              \n                        has_multiple_buttons: true            \n                    })          \n                },          \n                {            \n                    name: \"call_permission_request\",            \n                    buttonParamsJson: JSON.stringify({              \n                        has_multiple_buttons: true            \n                    })          \n                },          \n                {            \n                    name: \"single_select\",            \n                    buttonParamsJson: JSON.stringify({              \n                        title: \"Hello World\",              \n                        sections: [                \n                            {                  \n                                title: \"title\",                  \n                                highlight_label: \"label\",                  \n                                rows: [                    \n                                    {                      \n                                        title: \"@dhikzx\",                      \n                                        description: \"love you\",                      \n                                        id: \"row_2\"                    \n                                    }                  \n                                ]                \n                            }              \n                        ],              \n                        has_multiple_buttons: true            \n                    })          \n                },          \n                {            \n                    name: \"cta_copy\",            \n                    buttonParamsJson: JSON.stringify({              \n                        display_text: \"copy code\",              \n                        id: \"123456789\",              \n                        copy_code: \"ABC123XYZ\"            \n                    })          \n                }        \n            ]      \n        }    \n    }  \n}, { quoted: m });\n```\n\n#### Interactive\n```javascript\n- Example non header media\nawait sock.sendMessage(\n    jid,\n    {\n        text: \"Description Of Messages\", //Additional information\n        title: \"Title Of Messages\",\n        subtitle: \"Subtitle Message\",\n        footer: \"Footer Messages\",\n        interactiveButtons: [\n             {\n                name: \"quick_reply\",\n                buttonParamsJson: JSON.stringify({\n                     display_text: \"Display Button\",\n                     id: \"ID\"\n                })\n             },\n             {\n                name: \"cta_url\",\n                buttonParamsJson: JSON.stringify({\n                     display_text: \"Display Button\",\n                     url: \"https://www.example.com\"\n                })\n             }\n        ]\n    },\n  { quoted : message }\n)\n\n- Example with media\nawait sock.sendMessage(\n    jid,\n    {\n        image: { url : \"https://example.jpg\" }, // Can buffer\n        caption: \"Description Of Messages\", //Additional information\n        title: \"Title Of Messages\",\n        subtitle: \"Subtile Message\",\n        footer: \"Footer Messages\",\n        media: true,\n        interactiveButtons: [\n             {\n                name: \"quick_reply\",\n                buttonParamsJson: JSON.stringify({\n                     display_text: \"Display Button\",\n                     id: \"ID\"\n                })\n             },\n             {\n                name: \"cta_url\",\n                buttonParamsJson: JSON.stringify({\n                     display_text: \"Display Button\",\n                     url: \"https://www.example.com\"\n                })\n             }\n        ]\n    },\n  { quoted : message }\n)\n\n- Example with header product\nawait sock.sendMessage(\n    jid,\n    {\n        product: {\n            productImage: { url: \"https://example.jpg }, //or buffer\n            productImageCount: 1,\n            title: \"Title Product\",\n            description: \"Description Product\",\n            priceAmount1000: 20000 * 1000,\n            currencyCode: \"IDR\",\n            retailerId: \"Retail\",\n            url: \"https://example.com\",            \n        },\n        businessOwnerJid: \"1234@s.whatsapp.net\",\n        caption: \"Description Of Messages\", //Additional information\n        title: \"Title Of Messages\",\n        footer: \"Footer Messages\",\n        media: true,\n        interactiveButtons: [\n             {\n                name: \"quick_reply\",\n                buttonParamsJson: JSON.stringify({\n                     display_text: \"Display Button\",\n                     id: \"ID\"\n                })\n             },\n             {\n                name: \"cta_url\",\n                buttonParamsJson: JSON.stringify({\n                     display_text: \"Display Button\",\n                     url: \"https://www.example.com\"\n                })\n             }\n        ]\n    },\n  { quoted : message }\n)\n```\n\n#### Forward Messages\n- You need to have message object, can be retrieved from [store](#implementing-a-data-store) or use a [message](https://baileys.whiskeysockets.io/types/WAMessage.html) object\n```javascript\nconst msg = getMessageFromStore() // implement this on your end\nawait sock.sendMessage(jid, { forward: msg }) // WA forward the message!\n```\n\n#### Location Message\n```javascript\nawait sock.sendMessage(\n    jid,\n    {\n        location: {\n            degreesLatitude: 24.121231,\n            degreesLongitude: 55.1121221\n        }\n    }\n)\n```\n#### Contact Message\n```javascript\nconst vcard = 'BEGIN:VCARD\\n' // metadata of the contact card\n            + 'VERSION:3.0\\n'\n            + 'FN:Jeff Singh\\n' // full name\n            + 'ORG:Ashoka Uni;\\n' // the organization of the contact\n            + 'TEL;type=CELL;type=VOICE;waid=911234567890:+91 12345 67890\\n' // WhatsApp ID + phone number\n            + 'END:VCARD'\n\nawait sock.sendMessage(\n    id,\n    {\n        contacts: {\n            displayName: 'Jeff',\n            contacts: [{ vcard }]\n        }\n    }\n)\n```\n\n#### Reaction Message\n- You need to pass the key of message, you can retrieve from [store](#implementing-a-data-store) or use a [key](https://baileys.whiskeysockets.io/types/WAMessageKey.html) object\n```javascript\nawait sock.sendMessage(\n    jid,\n    {\n        react: {\n            text: '💖', // use an empty string to remove the reaction\n            key: message.key\n        }\n    }\n)\n```\n\n#### Pin Message\n- You need to pass the key of message, you can retrieve from [store](#implementing-a-data-store) or use a [key](https://baileys.whiskeysockets.io/types/WAMessageKey.html) object\n\n- Time can be:\n\n| Time  | Seconds        |\n|-------|----------------|\n| 24h    | 86.400        |\n| 7d     | 604.800       |\n| 30d    | 2.592.000     |\n\n```javascript\nawait sock.sendMessage(\n    jid,\n    {\n        pin: {\n            type: 1, // 0 to remove\n            time: 86400\n            key: message.key\n        }\n    }\n)\n```\n\n#### Keep Message\n- You need to pass the key of message, you can retrieve from [store](#implementing-a-data-store) or use a [key](https://baileys.whiskeysockets.io/types/WAMessageKey.html) object\n\n- Time can be:\n\n| Time  | Seconds        |\n|-------|----------------|\n| 24h    | 86.400        |\n| 7d     | 604.800       |\n| 30d    | 2.592.000     |\n\n```javascript\nawait sock.sendMessage(\n    jid,\n    {\n        keep: message.key,\n        type: 1, // 2 to unpin\n        time: 86400    \n    }\n)\n```\n\n#### Poll Message\n```javascript\nawait sock.sendMessage(\n    jid,\n    {\n        poll: {\n            name: 'My Poll',\n            values: ['Option 1', 'Option 2', ...],\n            selectableCount: 1,\n            toAnnouncementGroup: false // or true\n        }\n    }\n)\n```\n\n### Sending Messages with Link Previews\n\n1. By default, wa does not have link generation when sent from the web\n2. Baileys has a function to generate the content for these link previews\n3. To enable this function's usage, add `link-preview-js` as a dependency to your project with `yarn add link-preview-js`\n4. Send a link:\n```javascript\nawait sock.sendMessage(\n    jid,\n    {\n        text: 'Hi, this was sent using https://github.com/whiskeysockets/baileys'\n    }\n)\n```\n\n### Media Messages\n\nSending media (video, stickers, images) is easier & more efficient than ever.\n\n> [!NOTE]\n> In media messages, you can pass `{ stream: Stream }` or `{ url: Url }` or `Buffer` directly, you can see more [here](https://baileys.whiskeysockets.io/types/WAMediaUpload.html)\n\n- When specifying a media url, Baileys never loads the entire buffer into memory; it even encrypts the media as a readable stream.\n\n> [!TIP]\n> It's recommended to use Stream or Url to save memory\n\n#### Gif Message\n- Whatsapp doesn't support `.gif` files, that's why we send gifs as common `.mp4` video with `gifPlayback` flag\n```javascript\nawait sock.sendMessage(\n    jid,\n    {\n        video: fs.readFileSync('Media/ma_gif.mp4'),\n        caption: 'hello word',\n        gifPlayback: true\n    }\n)\n```\n\n#### Video Message\n```javascript\nawait sock.sendMessage(\n    id,\n    {\n        video: {\n            url: './Media/ma_gif.mp4'\n        },\n        caption: 'hello word',\n            ptv: false // if set to true, will send as a `video note`\n    }\n)\n```\n\n#### Audio Message\n- To audio message work in all devices you need to convert with some tool like `ffmpeg` with this flags:\n    ```bash\n        codec: libopus //ogg file\n        ac: 1 //one channel\n        avoid_negative_ts\n        make_zero\n    ```\n    - Example:\n    ```bash\n    ffmpeg -i input.mp4 -avoid_negative_ts make_zero -ac 1 output.ogg\n    ```\n```javascript\nawait sock.sendMessage(\n    jid,\n    {\n        audio: {\n            url: './Media/audio.mp3'\n        },\n        mimetype: 'audio/mp4'\n    }\n)\n```\n\n#### Image Message\n```javascript\nawait sock.sendMessage(\n    id,\n    {\n        image: {\n            url: './Media/ma_img.png'\n        },\n        caption: 'hello word'\n    }\n)\n```\n\n#### View Once Message\n\n- You can send all messages above as `viewOnce`, you only need to pass `viewOnce: true` in content object\n\n```javascript\nawait sock.sendMessage(\n    id,\n    {\n        image: {\n            url: './Media/ma_img.png'\n        },\n        viewOnce: true, //works with video, audio too\n        caption: 'hello word'\n    }\n)\n```\n\n## Modify Messages\n\n### Deleting Messages (for everyone)\n\n```javascript\nconst msg = await sock.sendMessage(jid, { text: 'hello word' })\nawait sock.sendMessage(jid, { delete: msg.key })\n```\n\n**Note:** deleting for oneself is supported via `chatModify`, see in [this section](#modifying-chats)\n\n### Editing Messages\n\n- You can pass all editable contents here\n```javascript\nawait sock.sendMessage(jid, {\n      text: 'updated text goes here',\n      edit: response.key,\n    });\n```\n\n## Manipulating Media Messages\n\n### Thumbnail in Media Messages\n- For media messages, the thumbnail can be generated automatically for images & stickers provided you add `jimp` or `sharp` as a dependency in your project using `yarn add jimp` or `yarn add sharp`.\n- Thumbnails for videos can also be generated automatically, though, you need to have `ffmpeg` installed on your system.\n\n### Downloading Media Messages\n\nIf you want to save the media you received\n```javascript\nconst { createWriteStream } = require('fs');\nconst { downloadMediaMessage, getContentType } = require(\"@dhikzx/baileys\");\n\nsock.ev.on('messages.upsert', async ({ [m] }) => {\n    if (!m.message) return // if there is no text or media message\n    const messageType = getContentType(m) // get what type of message it is (text, image, video...)\n\n    // if the message is an image\n    if (messageType === 'imageMessage') {\n        // download the message\n        const stream = await downloadMediaMessage(\n            m,\n            'stream', // can be 'buffer' too\n            { },\n            {\n                logger,\n                // pass this so that baileys can request a reupload of media\n                // that has been deleted\n                reuploadRequest: sock.updateMediaMessage\n            }\n        )\n        // save to file\n        const writeStream = createWriteStream('./my-download.jpeg')\n        stream.pipe(writeStream)\n    }\n}\n```\n\n### Re-upload Media Message to Whatsapp\n\n- WhatsApp automatically removes old media from their servers. For the device to access said media -- a re-upload is required by another device that has it. This can be accomplished using:\n```javascript\nawait sock.updateMediaMessage(msg)\n```\n\n## Reject Call\n\n- You can obtain `callId` and `callFrom` from `call` event\n\n```javascript\nawait sock.rejectCall(callId, callFrom)\n```\n\n## Send States in Chat\n\n### Reading Messages\n- A set of message [keys](https://baileys.whiskeysockets.io/types/WAMessageKey.html) must be explicitly marked read now.\n- You cannot mark an entire 'chat' read as it were with Baileys Web.\nThis means you have to keep track of unread messages.\n\n```javascript\nconst key: WAMessageKey\n// can pass multiple keys to read multiple messages as well\nawait sock.readMessages([key])\n```\n\nThe message ID is the unique identifier of the message that you are marking as read.\nOn a `WAMessage`, the `messageID` can be accessed using ```messageID = message.key.id```.\n\n### Update Presence\n\n- ``` presence ``` can be one of [these](https://baileys.whiskeysockets.io/types/WAPresence.html)\n- The presence expires after about 10 seconds.\n- This lets the person/group with `jid` know whether you're online, offline, typing etc.\n\n```javascript\nawait sock.sendPresenceUpdate('available', jid)\n```\n\n> [!NOTE]\n> If a desktop client is active, WA doesn't send push notifications to the device. If you would like to receive said notifications -- mark your Baileys client offline using `sock.sendPresenceUpdate('unavailable')`\n\n## Modifying Chats\n\nWA uses an encrypted form of communication to send chat/app updates. This has been implemented mostly and you can send the following updates:\n\n> [!IMPORTANT]\n> If you mess up one of your updates, WA can log you out of all your devices and you'll have to log in again.\n\n### Archive a Chat\n```javascript\nconst lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end\nawait sock.chatModify({ archive: true, lastMessages: [lastMsgInChat] }, jid)\n```\n### Mute/Unmute a Chat\n\n- Supported times:\n\n| Time  | Miliseconds     |\n|-------|-----------------|\n| Remove | null           |\n| 8h     | 86.400.000     |\n| 7d     | 604.800.000    |\n\n```javascript\n// mute for 8 hours\nawait sock.chatModify({ mute: 8 * 60 * 60 * 1000 }, jid)\n// unmute\nawait sock.chatModify({ mute: null }, jid)\n```\n### Mark a Chat Read/Unread\n```javascript\nconst lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end\n// mark it unread\nawait sock.chatModify({ markRead: false, lastMessages: [lastMsgInChat] }, jid)\n```\n\n### Delete a Message for Me\n```javascript\nawait sock.chatModify(\n    {\n        clear: {\n            messages: [\n                {\n                    id: 'ATWYHDNNWU81732J',\n                    fromMe: true,\n                    timestamp: '1654823909'\n                }\n            ]\n        }\n    },\n    jid\n)\n\n```\n### Delete a Chat\n```javascript\nconst lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end\nawait sock.chatModify({\n        delete: true,\n        lastMessages: [\n            {\n                key: lastMsgInChat.key,\n                messageTimestamp: lastMsgInChat.messageTimestamp\n            }\n        ]\n    },\n    jid\n)\n```\n### Pin/Unpin a Chat\n```javascript\nawait sock.chatModify({\n        pin: true // or `false` to unpin\n    },\n    jid\n)\n```\n### Star/Unstar a Message\n```javascript\nawait sock.chatModify({\n        star: {\n            messages: [\n                {\n                    id: 'messageID',\n                    fromMe: true // or `false`\n                }\n            ],\n            star: true // - true: Star Message; false: Unstar Message\n        }\n    },\n    jid\n)\n```\n\n### Disappearing Messages\n\n- Ephemeral can be:\n\n| Time  | Seconds        |\n|-------|----------------|\n| Remove | 0          |\n| 24h    | 86.400     |\n| 7d     | 604.800    |\n| 90d    | 7.776.000  |\n\n- You need to pass in **Seconds**, default is 7 days\n\n```javascript\n// turn on disappearing messages\nawait sock.sendMessage(\n    jid,\n    // this is 1 week in seconds -- how long you want messages to appear for\n    { disappearingMessagesInChat: WA_DEFAULT_EPHEMERAL }\n)\n\n// will send as a disappearing message\nawait sock.sendMessage(jid, { text: 'hello' }, { ephemeralExpiration: WA_DEFAULT_EPHEMERAL })\n\n// turn off disappearing messages\nawait sock.sendMessage(\n    jid,\n    { disappearingMessagesInChat: false }\n)\n```\n\n## User Querys\n\n### Check If ID Exists in Whatsapp\n```javascript\nconst [result] = await sock.onWhatsApp(jid)\nif (result.exists) console.log (`${jid} exists on WhatsApp, as jid: ${result.jid}`)\n```\n\n### Query Chat History (groups too)\n\n- You need to have oldest message in chat\n```javascript\nconst msg = await getOldestMessageInChat(jid)\nawait sock.fetchMessageHistory(\n    50, //quantity (max: 50 per query)\n    msg.key,\n    msg.messageTimestamp\n)\n```\n- Messages will be received in `messaging.history-set` event\n\n### Fetch User Lid\n```javascript\nconst jid = \"123456789@s.whatsapp.net\"\nconst lid = await sock.fetchUserLid(jid)\nconsole.log('user lid: ' + lid)\n```\n\n### Fetch Status\n```javascript\nconst status = await sock.fetchStatus(jid)\nconsole.log('status: ' + status)\n```\n\n### Fetch Profile Picture (groups too)\n- To get the display picture of some person/group/newsletter\n```javascript\n// for low res picture\nconst ppUrl = await sock.profilePictureUrl(jid)\nconsole.log(ppUrl)\n\n// for high res picture\nconst ppUrl = await sock.profilePictureUrl(jid, 'image')\n```\n\n### Fetch Bussines Profile (such as description or category)\n```javascript\nconst profile = await sock.getBusinessProfile(jid)\nconsole.log('business description: ' + profile.description + ', category: ' + profile.category)\n```\n\n### Fetch Someone's Presence (if they're typing or online)\n```javascript\n// the presence update is fetched and called here\nsock.ev.on('presence.update', console.log)\n\n// request updates for a chat\nawait sock.presenceSubscribe(jid)\n```\n\n## Change Profile\n\n### Change Profile Status\n```javascript\nawait sock.updateProfileStatus('Hello World!')\n```\n### Change Profile Name\n```javascript\nawait sock.updateProfileName('My name')\n```\n### Change Display Picture (groups too)\n- To change your display picture or a group's\n\n> [!NOTE]\n> Like media messages, you can pass `{ stream: Stream }` or `{ url: Url }` or `Buffer` directly, you can see more [here](https://baileys.whiskeysockets.io/types/WAMediaUpload.html)\n\n```javascript\nawait sock.updateProfilePicture(jid, { url: './new-profile-picture.jpeg' })\n```\n### Remove display picture (groups too)\n```javascript\nawait sock.removeProfilePicture(jid)\n```\n\n## Groups\n\n- To change group properties you need to be admin\n\n### Create a Group\n```javascript\n// title & participants\nconst group = await sock.groupCreate('My Fab Group', ['1234@s.whatsapp.net', '4564@s.whatsapp.net'])\nconsole.log('created group with id: ' + group.gid)\nawait sock.sendMessage(group.id, { text: 'hello there' }) // say hello to everyone on the group\n```\n### Add/Remove or Demote/Promote\n```javascript\n// id & people to add to the group (will throw error if it fails)\nawait sock.groupParticipantsUpdate(\n    jid,\n    ['abcd@s.whatsapp.net', 'efgh@s.whatsapp.net'],\n    'add' // replace this parameter with 'remove' or 'demote' or 'promote'\n)\n```\n### Change Subject (name)\n```javascript\nawait sock.groupUpdateSubject(jid, 'New Subject!')\n```\n### Change Description\n```javascript\nawait sock.groupUpdateDescription(jid, 'New Description!')\n```\n### Change Settings\n```javascript\n// only allow admins to send messages\nawait sock.groupSettingUpdate(jid, 'announcement')\n// allow everyone to send messages\nawait sock.groupSettingUpdate(jid, 'not_announcement')\n// allow everyone to modify the group's settings -- like display picture etc.\nawait sock.groupSettingUpdate(jid, 'unlocked')\n// only allow admins to modify the group's settings\nawait sock.groupSettingUpdate(jid, 'locked')\n```\n### Leave a Group\n```javascript\n// will throw error if it fails\nawait sock.groupLeave(jid)\n```\n### Get Invite Code\n- To create link with code use `'https://chat.whatsapp.com/' + code`\n```javascript\nconst code = await sock.groupInviteCode(jid)\nconsole.log('group code: ' + code)\n```\n### Revoke Invite Code\n```javascript\nconst code = await sock.groupRevokeInvite(jid)\nconsole.log('New group code: ' + code)\n```\n### Join Using Invitation Code\n- Code can't have `https://chat.whatsapp.com/`, only code\n```javascript\nconst response = await sock.groupAcceptInvite(code)\nconsole.log('joined to: ' + response)\n```\n### Get Group Info by Invite Code\n```javascript\nconst response = await sock.groupGetInviteInfo(code)\nconsole.log('group information: ' + response)\n```\n### Query Metadata (participants, name, description...)\n```javascript\nconst metadata = await sock.groupMetadata(jid)\nconsole.log(metadata.id + ', title: ' + metadata.subject + ', description: ' + metadata.desc)\n```\n### Join using `groupInviteMessage`\n```javascript\nconst response = await sock.groupAcceptInviteV4(jid, groupInviteMessage)\nconsole.log('joined to: ' + response)\n```\n### Get Request Join List\n```javascript\nconst response = await sock.groupRequestParticipantsList(jid)\nconsole.log(response)\n```\n### Approve/Reject Request Join\n```javascript\nconst response = await sock.groupRequestParticipantsUpdate(\n    jid, // group id\n    ['abcd@s.whatsapp.net', 'efgh@s.whatsapp.net'],\n    'approve' // or 'reject'\n)\nconsole.log(response)\n```\n### Get All Participating Groups Metadata\n```javascript\nconst response = await sock.groupFetchAllParticipating()\nconsole.log(response)\n```\n### Toggle Ephemeral\n\n- Ephemeral can be:\n\n| Time  | Seconds        |\n|-------|----------------|\n| Remove | 0          |\n| 24h    | 86.400     |\n| 7d     | 604.800    |\n| 90d    | 7.776.000  |\n\n```javascript\nawait sock.groupToggleEphemeral(jid, 86400)\n```\n\n### Change Add Mode\n```javascript\nawait sock.groupMemberAddMode(\n    jid,\n    'all_member_add' // or 'admin_add'\n)\n```\n\n## Privacy\n\n### Block/Unblock User\n```javascript\nawait sock.updateBlockStatus(jid, 'block') // Block user\nawait sock.updateBlockStatus(jid, 'unblock') // Unblock user\n```\n### Get Privacy Settings\n```javascript\nconst privacySettings = await sock.fetchPrivacySettings(true)\nconsole.log('privacy settings: ' + privacySettings)\n```\n### Get BlockList\n```javascript\nconst response = await sock.fetchBlocklist()\nconsole.log(response)\n```\n### Update LastSeen Privacy\n```javascript\nconst value = 'all' // 'contacts' | 'contact_blacklist' | 'none'\nawait sock.updateLastSeenPrivacy(value)\n```\n### Update Online Privacy\n```javascript\nconst value = 'all' // 'match_last_seen'\nawait sock.updateOnlinePrivacy(value)\n```\n### Update Profile Picture Privacy\n```javascript\nconst value = 'all' // 'contacts' | 'contact_blacklist' | 'none'\nawait sock.updateProfilePicturePrivacy(value)\n```\n### Update Status Privacy\n```javascript\nconst value = 'all' // 'contacts' | 'contact_blacklist' | 'none'\nawait sock.updateStatusPrivacy(value)\n```\n### Update Read Receipts Privacy\n```javascript\nconst value = 'all' // 'none'\nawait sock.updateReadReceiptsPrivacy(value)\n```\n### Update Groups Add Privacy\n```javascript\nconst value = 'all' // 'contacts' | 'contact_blacklist'\nawait sock.updateGroupsAddPrivacy(value)\n```\n### Update Default Disappearing Mode\n\n- Like [this](#disappearing-messages), ephemeral can be:\n\n| Time  | Seconds        |\n|-------|----------------|\n| Remove | 0          |\n| 24h    | 86.400     |\n| 7d     | 604.800    |\n| 90d    | 7.776.000  |\n\n```javascript\nconst ephemeral = 86400\nawait sock.updateDefaultDisappearingMode(ephemeral)\n```\n\n## Broadcast Lists & Stories\n\n### Send Broadcast & Stories\n- Messages can be sent to broadcasts & stories. You need to add the following message options in sendMessage, like this:\n```javascript\nawait sock.sendMessage(\n    jid,\n    {\n        image: {\n            url: url\n        },\n        caption: caption\n    },\n    {\n        backgroundColor: backgroundColor,\n        font: font,\n        statusJidList: statusJidList,\n        broadcast: true\n    }\n)\n```\n- Message body can be a `extendedTextMessage` or `imageMessage` or `videoMessage` or `voiceMessage`, see [here](https://baileys.whiskeysockets.io/types/AnyRegularMessageContent.html)\n- You can add `backgroundColor` and other options in the message options, see [here](https://baileys.whiskeysockets.io/types/MiscMessageGenerationOptions.html)\n- `broadcast: true` enables broadcast mode\n- `statusJidList`: a list of people that you can get which you need to provide, which are the people who will get this status message.\n\n- You can send messages to broadcast lists the same way you send messages to groups & individual chats.\n- Right now, WA Web does not support creating broadcast lists, but you can still delete them.\n- Broadcast IDs are in the format `12345678@broadcast`\n### Query a Broadcast List's Recipients & Name\n```javascript\nconst bList = await sock.getBroadcastListInfo('1234@broadcast')\nconsole.log (`list name: ${bList.name}, recps: ${bList.recipients}`)\n```\n\n## Writing Custom Functionality\nBaileys is written with custom functionality in mind. Instead of forking the project & re-writing the internals, you can simply write your own extensions.\n\n### Enabling Debug Level in Baileys Logs\nFirst, enable the logging of unhandled messages from WhatsApp by setting:\n```javascript\nconst sock = makeWASocket({\n    logger: P({ level: 'debug' }),\n})\n```\nThis will enable you to see all sorts of messages WhatsApp sends in the console.\n\n### How Whatsapp Communicate With Us\n\n> [!TIP]\n> If you want to learn whatsapp protocol, we recommend to study about Libsignal Protocol and Noise Protocol\n\n- **Example:** Functionality to track the battery percentage of your phone. You enable logging and you'll see a message about your battery pop up in the console:\n    ```\n    {\n        \"level\": 10,\n        \"fromMe\": false,\n        \"frame\": {\n            \"tag\": \"ib\",\n            \"attrs\": {\n                \"from\": \"@s.whatsapp.net\"\n            },\n            \"content\": [\n                {\n                    \"tag\": \"edge_routing\",\n                    \"attrs\": {},\n                    \"content\": [\n                        {\n                            \"tag\": \"routing_info\",\n                            \"attrs\": {},\n                            \"content\": {\n                                \"type\": \"Buffer\",\n                                \"data\": [8,2,8,5]\n                            }\n                        }\n                    ]\n                }\n            ]\n        },\n        \"msg\":\"communication\"\n    }\n    ```\n\nThe `'frame'` is what the message received is, it has three components:\n- `tag` -- what this frame is about (eg. message will have 'message')\n- `attrs` -- a string key-value pair with some metadata (contains ID of the message usually)\n- `content` -- the actual data (eg. a message node will have the actual message content in it)\n- read more about this format [here](/src/WABinary/readme.md)\n\n### Register a Callback for Websocket Events\n\n> [!TIP]\n> Recommended to see `onMessageReceived` function in `socket.ts` file to understand how websockets events are fired\n\n```javascript\n// for any message with tag 'edge_routing'\nsock.ws.on('CB:edge_routing', (node: BinaryNode) => { })\n\n// for any message with tag 'edge_routing' and id attribute = abcd\nsock.ws.on('CB:edge_routing,id:abcd', (node: BinaryNode) => { })\n\n// for any message with tag 'edge_routing', id attribute = abcd & first content node routing_info\nsock.ws.on('CB:edge_routing,id:abcd,routing_info', (node: BinaryNode) => { })\n```\n\n> [!NOTE]\n> Also, this repo is now licenced under GPL 3 since it uses [libsignal-node](https://git.questbook.io/backend/service-coderunner/-/merge_requests/1)\n","readmeFilename":"README.md","homepage":"https://github.com/WhiskeySockets/Baileys/","keywords":["baileys","baileys-mod","bails","whiskeysockets/baileys","whatsapp","meta","Hydra","Kelvdra","whatsapp","js-whatsapp","whatsapp-api","whatsapp-web","whatsapp-chat","whatsapp-group","automation","multi-device","modder"],"repository":{"url":"git+ssh://git@github.com/WhiskeySockets/Baileys.git"},"author":{"name":"Kelvdra"},"bugs":{"url":"https://github.com/WhiskeySockets/Baileys/issues"}}