TRASHCORE_ BAILEYS GUIDE

Your complete documentation for using @trashcore/baileys

Modern WhatsApp API Library for Node.js · v4.2.7

Installation Methods

Choose the method that best fits your development needs:

1. Stable Release (Recommended)

Install the latest stable version from npm. Best for production.

package.json
"dependencies": {
  "@trashcore/baileys": "latest"
}

Install the exact stable version from npm.

package.json
"dependencies": {
  "@trashcore/baileys": "^4.2.7"
}

Then run:

npm install

2. GitHub Repository (Dev Build)

Install directly from the official GitHub repo for the latest features (may be unstable).

package.json
"dependencies": {
  "@trashcore/baileys": "github:Tennor-modz/MD-Baileys"
}

Or install via CLI:

npm install github:Tennor-modz/MD-Baileys

3. Custom Fork

Use your own or a modified fork for custom features or fixes.

package.json
"dependencies": {
  "@trashcore/baileys": "github:your-username/baileys"
}

Replace your-username with your GitHub handle.

npm install

4. Drop-in for @whiskeysockets/baileys

Keep your existing imports by aliasing the package.

package.json
"dependencies": {
  "@whiskeysockets/baileys": "npm:@trashcore/baileys@latest"
}

What's New & Fixed

What's Fixed

  • Bad MAC / Decrypt Errors (4.2.7): Fixed "Failed to decrypt message with any known session" by making the Signal layer LID-aware, with automatic session migration.
  • Safer Key Commits (4.2.7): Failed key-store writes are no longer swallowed, which prevents sessions from silently desyncing.
  • Private Chat Replies (4.2.7): Fixed bots replying in groups but not in DMs. An AI bot node was attached to every 1-to-1 message by default; it is now opt-in.
  • Self-Chat / Own Device (4.2.7): Your own device is now matched by LID too, so the bot no longer tries to encrypt messages to itself.
  • Device 99 Send Crash (4.2.7): Hosted / Cloud-API companion devices are now skipped, so replies no longer fail with "Unexpected non-hosted device JID with device 99".
  • Identity Change Detection (4.2.7): Contacts who re-register now get their stale session cleared correctly.
  • Low-RAM Compatibility: Now installable and runnable on servers with as little as 512MB RAM — optimized memory usage for budget hosting.
  • Device Linking Stability: Fixed persistent issues with pairing and reconnecting multi-device sessions.
  • Fixed libsignal install error: Resolved dependency installation issues with libsignal, ensuring smooth setup across all environments.

Cool Features

  • WhatsApp Business Buttons: Fully support interactive reply buttons, list menus, and CTAs for WhatsApp Business accounts.
  • Advanced LID (Linked Identity) Features: Improved session persistence, faster reconnection, and seamless cross-device message sync.

Quick Start

Get your bot running in minutes with this simple setup:

const {
  default: TrashcoreConnect 
} = require('@trashcore/baileys');

async function startBot() { 
  const trashcore = await TrashcoreConnect({ 
    printQRInTerminal: true 
  });

  trashcore.ev.on('messages.upsert', async (m) => { 
    const msg = m.messages[0]; 
    if (!msg.message) return;

    const text = msg.message.conversation;

    if (text === 'ping') {
      await trashcore.sendMessage(msg.key.remoteJid, { text: 'pong!' });
    }
  });

  // Custom pairing example 
  const phoneNumber = '+1234567890'; 
  const cleanNumber = phoneNumber.replace(/[^0-9]/g, ''); 
  console.clear(); 
  const custom = "TRASHBOT"; 
  const pairCode = await trashcore.requestPairingCode(cleanNumber, custom); 
}

startBot();

Browser Setup

Configure the browser environment for optimal performance:

browser: ["Ubuntu", "Opera", "100.0.4815.0"]

Project Structure

Organize your project with this recommended structure:

my-bot/
├── index.js
├── package.json
└── node_modules/

Common Errors & Fixes

ENOENT: git not found
pkg install git
Module not found
npm install
Bot replies in groups but not in private chats

Update to 4.2.7. Private-chat messages no longer carry the AI bot node by default.

npm install @trashcore/baileys@latest
Unexpected non-hosted device JID with device 99

Update to 4.2.7. Hosted companion devices are now skipped when sending.

npm install @trashcore/baileys@latest
Bad MAC after updating

Update to 4.2.7, then delete the old session files once (use your own auth folder name) and restart. Re-link the device if needed.

rm -rf session/session-*.json

Key Features

QR Authentication

Secure login with QR code scanning for WhatsApp Web sessions

Pairing Code

Alternative login method using phone number pairing

Fast Performance

Optimized for speed with minimal resource usage

Terminal Example

bash - index.js
user@machine:~/my-bot$ node index.js
[INFO] Connecting to WhatsApp...
[INFO] Generating QR code...
[QR] Scan this code with your phone
[SUCCESS] Connected to WhatsApp Web
[INFO] Bot is running and listening for messages
[MSG] Received: "ping"
[MSG] Sent: "pong!"

Available Packages

@trashcore/baileys @trashcore/multi-device @trashcore/utils @trashcore/events whatsapp-web.js qrcode-terminal