npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dylsx/baileys-br

v1.1.0

Published

Baileys BR - WhatsApp API Multi-Device

Readme

🇧🇷 Baileys BR - WhatsApp API Multi-Device

⚡ A mais poderosa implementação WhatsApp Multi-Device para Node.js ⚡

npm version Downloads Size License


📋 Sobre o Projeto

Baileys BR é uma implementação robusta e completa da API do WhatsApp Web Multi-Device para Node.js. Baseado no excelente trabalho da comunidade WhiskeySockets, este pacote traz melhorias significativas e funcionalidades extras para tornar sua experiência de desenvolvimento ainda mais produtiva.

✨ O que torna o Baileys BR especial?

  • Completamente em Português - Documentação e exemplos localizados
  • Exemplos em CJS e ESM - Suporte para ambos os sistemas de módulos
  • Recursos exclusivos - Funcionalidades extras não disponíveis no original
  • Totalmente tipado - TypeScript com tipos precisos
  • Atualizado constantemente - Sempre seguindo as últimas atualizações do WhatsApp

🚀 Instalação

NPM

npm install @dylsx/baileys-br

Yarn

yarn add @dylsx/baileys-br

PNPM

pnpm add @dylsx/baileys-br

📖 Exemplos de Uso

Exemplo Básico com CommonJS (CJS)

const { default: makeWASocket, useMultiFileAuthState } = require('@dylsx/baileys-br');
const { Boom } = require('@hapi/boom');
const P = require('pino');

async function connectToWhatsApp() {
  // Carrega estado de autenticação
  const { state, saveCreds } = await useMultiFileAuthState('auth_info');
  
  // Cria a conexão
  const sock = makeWASocket({
    auth: state,
    printQRInTerminal: true,
    logger: P({ level: 'silent' }),
    browser: ['Baileys BR', 'Chrome', '1.0.0'],
  });
  
  // Evento quando as credenciais são atualizadas
  sock.ev.on('creds.update', saveCreds);
  
  // Evento quando a conexão é atualizada
  sock.ev.on('connection.update', (update) => {
    const { connection, lastDisconnect } = update;
    
    if (connection === 'close') {
      const shouldReconnect = (lastDisconnect?.error)?.output?.statusCode !== 401;
      console.log('Conexão fechada, reconectando:', shouldReconnect);
      
      if (shouldReconnect) {
        connectToWhatsApp();
      }
    } else if (connection === 'open') {
      console.log('✅ Conectado com sucesso!');
      console.log('📱 Número:', sock.user?.id.split(':')[0]);
    }
  });
  
  // Evento para receber mensagens
  sock.ev.on('messages.upsert', async ({ messages, type }) => {
    const msg = messages[0];
    
    if (!msg.message || msg.key.fromMe) return;
    
    const text = msg.message.conversation || 
                 msg.message.extendedTextMessage?.text || 
                 '';
    
    const sender = msg.key.remoteJid;
    console.log(`📩 Mensagem de ${sender}: ${text}`);
    
    // Responde a comandos
    if (text === '!ping') {
      await sock.sendMessage(sender, { text: '🏓 Pong!' });
    }
    
    if (text === '!hora') {
      const agora = new Date().toLocaleString('pt-BR');
      await sock.sendMessage(sender, { text: `🕐 ${agora}` });
    }
  });
}

// Inicia o bot
connectToWhatsApp().catch(console.error);

Exemplo com TypeScript (ESM)

import makeWASocket, {
  useMultiFileAuthState,
  DisconnectReason,
  downloadMediaMessage,
} from '@dylsx/baileys-br';
import { Boom } from '@hapi/boom';
import * as fs from 'fs/promises';

async function startBot() {
  const { state, saveCreds } = await useMultiFileAuthState('./auth');
  
  const sock = makeWASocket({
    auth: state,
    printQRInTerminal: true,
    browser: ['Baileys BR', 'Safari', '1.0.0'],
    syncFullHistory: true,
  });
  
  sock.ev.on('creds.update', saveCreds);
  
  sock.ev.on('connection.update', (update) => {
    const { connection, lastDisconnect, qr } = update;
    
    if (qr) {
      console.log('📱 Escaneie o QR Code acima');
    }
    
    if (connection === 'close') {
      const shouldReconnect = (lastDisconnect?.error as Boom)?.output?.statusCode !== DisconnectReason.loggedOut;
      
      if (shouldReconnect) {
        console.log('🔄 Reconectando...');
        startBot();
      } else {
        console.log('❌ Deslogado permanentemente');
      }
    }
  });
  
  sock.ev.on('messages.upsert', async ({ messages }) => {
    const m = messages[0];
    
    if (!m.message || m.key.fromMe) return;
    
    // Download de mídia
    if (m.message.imageMessage) {
      const buffer = await downloadMediaMessage(m, 'buffer', {});
      await fs.writeFile(`./downloads/${Date.now()}.jpg`, buffer);
      console.log('📸 Imagem salva!');
    }
  });
  
  return sock;
}

startBot();

✨ Funcionalidades Exclusivas do Baileys BR

Além de todas as funcionalidades do Baileys original, adicionamos:

🆕 Mensagens para Canais

// Enviar mensagem para canal
await sock.sendMessage(channelJid, { 
  text: 'Olá canal!',
  isForwarded: true 
});

🆕 Botões e Mensagens Interativas

// Enviar botões
await sock.sendMessage(jid, {
  text: 'Escolha uma opção:',
  buttons: [
    { buttonId: '1', buttonText: { displayText: '✅ Sim' } },
    { buttonId: '2', buttonText: { displayText: '❌ Não' } }
  ],
  viewOnce: true
});

🆕 Código de Pareamento Customizado

// Gerar código de pareamento
const code = await sock.requestPairingCode('5511999999999');
console.log(`🔑 Código: ${code}`);

🆕 Ícone de IA nas Mensagens

// Mensagem com ícone de IA
await sock.sendMessage(jid, { 
  text: 'Resposta gerada por IA 🤖',
  aiMessage: true 
});

📚 Documentação

Para documentação completa e detalhada, visite:

👉 https://baileys.wiki 👈


🛠️ Requisitos

· Node.js 20.0.0 ou superior · Sistema operacional: Windows, Linux, macOS


📦 Estrutura do Projeto

@dylsx/baileys-br/
├── lib/          # Código compilado
├── WAProto/      # Protocol buffers do WhatsApp
├── examples/     # Exemplos de uso
└── docs/         # Documentação

🤝 Contribuindo

Contribuições são sempre bem-vindas! Veja como ajudar:

  1. Faça um fork do projeto
  2. Crie sua branch (git checkout -b feature/NovaFeature)
  3. Commit suas mudanças (git commit -m 'Adiciona nova feature')
  4. Push para a branch (git push origin feature/NovaFeature)
  5. Abra um Pull Request

📄 Licença

Este projeto está sob a licença MIT. Veja o arquivo LICENSE para mais detalhes.


⚠️ Aviso Importante

[!CAUTION] NOTA SOBRE MUDANÇAS CRÍTICAS

A partir da versão 7.0.0, várias mudanças significativas foram introduzidas. Consulte https://whiskey.so/migrate-latest para mais informações.


🌟 Créditos

Este projeto é baseado no excelente trabalho de:

· WhiskeySockets - Mantenedores do Baileys original · adiwajshing - Criador original do Baileys


Desenvolvido com ❤️ para a comunidade brasileira

https://img.shields.io/github/stars/dylsx/baileys-br?style=social https://img.shields.io/github/forks/dylsx/baileys-br?style=social