jian-library
Complete Baileys Extension with 100% Button Support and All Features
Installation
npm install jian-library
Usage
const { makeWASocket, useMultiFileAuthState } = require('@whiskeysockets/baileys');
const JianLibrary = require('jian-library');
async function startBot() {
const { state, saveCreds } = await useMultiFileAuthState('./session');
const sock = makeWASocket({
auth: state,
printQRInTerminal: true
});
new JianLibrary(sock);
sock.ev.on('creds.update', saveCreds);
sock.ev.on('messages.upsert', async ({ messages }) => {
const m = messages[0];
if (!m.message) return;
const text = m.message.conversation || '';
const from = m.key.remoteJid;
if (text === '.button') {
await sock.sendButton(from, {
text: 'Hello World!',
buttons: [
{ text: 'Button 1', id: 'btn1' },
{ text: 'Button 2', id: 'btn2' }
]
});
}
if (text === '.carousel') {
await sock.sendCard(from, {
text: 'Carousel Test',
cards: [
{
image: 'https://example.com/image1.jpg',
caption: 'Card 1',
buttons: [{ text: 'Select 1', id: 'card1' }]
},
{
image: 'https://example.com/image2.jpg',
caption: 'Card 2',
buttons: [{ text: 'Select 2', id: 'card2' }]
}
]
});
}
});
}
startBot();
Features
Button Types
✅ Quick Reply Button
✅ URL Button
✅ Call Button
✅ Copy Button
✅ List Message
✅ Carousel/Card Message
Media Features
✅ Send Image
✅ Send Video
✅ Send Sticker
✅ Send Album
✅ Send Document
✅ Send Audio
✅ Send Voice
Message Features
✅ Send Contact
✅ Send Poll
✅ Send Location
✅ Send Live Location
✅ Send Reaction
Group Features
✅ Create Group
✅ Update Group Settings
✅ Promote/Demote Participants
✅ Add/Remove Participants
✅ Get Invite Code
✅ Revoke Invite Code
Newsletter Features
✅ Create Newsletter
✅ Send Newsletter Message
✅ Follow/Unfollow Newsletter
✅ Update Newsletter Info
✅ Promote/Demote Newsletter Admin
Product Features
✅ Send Product
✅ Send Catalog
✅ Send Order
Payment Features
✅ Send Payment
✅ Send Payment Request
✅ Send Payment Invite
Examples
Quick Reply Button
await sock.sendQuickReply('628xxx@s.whatsapp.net', {
text: 'Choose an option',
buttons: [
{ text: 'Option 1', id: 'opt1' },
{ text: 'Option 2', id: 'opt2' },
{ text: 'Option 3', id: 'opt3' }
]
});
URL Button
await sock.sendUrlButton('628xxx@s.whatsapp.net', {
text: 'Visit our website',
buttons: [
{ text: 'Google', url: 'https://google.com' },
{ text: 'GitHub', url: 'https://github.com' }
]
});
Call Button
await sock.sendCallButton('628xxx@s.whatsapp.net', {
text: 'Contact us',
buttons: [
{ text: 'Call Now', phoneNumber: '628123456789' }
]
});
Copy Button
await sock.sendCopyButton('628xxx@s.whatsapp.net', {
text: 'Copy this code',
buttons: [
{ text: 'Copy Code', code: 'ABC123XYZ' }
]
});
Carousel/Card Message
await sock.sendCard('628xxx@s.whatsapp.net', {
text: 'Choose a product',
cards: [
{
image: 'https://example.com/product1.jpg',
caption: 'Product 1 - $10',
buttons: [
{ text: 'Buy Now', id: 'buy_1' }
]
},
{
image: 'https://example.com/product2.jpg',
caption: 'Product 2 - $20',
buttons: [
{ text: 'Buy Now', id: 'buy_2' }
]
}
]
});
List Message
await sock.sendList('628xxx@s.whatsapp.net', {
text: 'Select from list',
buttonText: 'Click Here',
sections: [
{
title: 'Category 1',
rows: [
{ title: 'Item 1', description: 'Description 1', id: 'item1' },
{ title: 'Item 2', description: 'Description 2', id: 'item2' }
]
},
{
title: 'Category 2',
rows: [
{ title: 'Item 3', description: 'Description 3', id: 'item3' }
]
}
]
});
Send Product
await sock.sendProduct('628xxx@s.whatsapp.net', {
image: 'https://example.com/product.jpg',
productName: 'Cool Product',
description: 'This is a cool product',
price: '100000',
currency: 'IDR'
});
Send Poll
await sock.sendPoll('628xxx@s.whatsapp.net', {
name: 'Vote for your favorite',
values: ['Option A', 'Option B', 'Option C'],
selectableCount: 1
});
Send Contact
await sock.sendContact('628xxx@s.whatsapp.net', [
{ name: 'John Doe', number: '628123456789' },
{ name: 'Jane Doe', number: '628987654321' }
]);
Create Newsletter
const newsletter = await sock.createNewsletter('My Newsletter', 'Newsletter description');
console.log('Newsletter created:', newsletter);
Utils
const { Utils } = require('jian-library');
const buffer = await Utils.getBuffer('https://example.com/image.jpg');
const id = Utils.generateId();
await Utils.sleep(1000);
const number = Utils.formatNumber('+62 812-3456-7890');
const isUrl = Utils.isUrl('https://google.com');
const mentions = Utils.parseMention('Hello @628123456789');
License
MIT
Author
Jian
Support
For issues and questions, please visit: GitHub Issues
---