npm package: @nexuo/core
Description: WhatsApp button helper for Baileys - Mudah kirim button, list, dan interactive message
Author: 4rnzz
Latest version: 1.0.0

::: {align="center"}
# @nexuo/core

[![npm
version](https://img.shields.io/npm/v/@nexuo/core.svg?style=for-the-badge)](https://www.npmjs.com/package/@nexuo/core)
[![npm
downloads](https://img.shields.io/npm/dm/@nexuo/core.svg?style=for-the-badge)](https://www.npmjs.com/package/@nexuo/core)
[![License](https://img.shields.io/npm/l/@nexuo/core.svg?style=for-the-badge)](LICENSE)
[![Node](https://img.shields.io/badge/node-%3E%3D20-blue?style=for-the-badge)](https://nodejs.org)

Lightweight helper for WhatsApp interactive messages using Baileys.

Built to keep your bot code clean, minimal, and consistent.
:::

------------------------------------------------------------------------

## Overview

Writing interactive WhatsApp messages with Baileys can be repetitive and
messy.

`@nexuo/core` extends the Baileys socket with a convenient `sendButton`
method and automatic button response parsing, helping you reduce
boilerplate and standardize your bot handler.

------------------------------------------------------------------------

## Features

-   Multiple button types (quick reply, URL, copy code, phone)\
-   Interactive list menu support\
-   Built-in external ad reply support\
-   Automatic mention parsing\
-   Full `contextInfo` control\
-   Response normalization into `m.text`

------------------------------------------------------------------------

## Requirements

  Dependency   Version
  ------------ --------------
  Node.js      \>= 20
  Baileys      \^7.0.0-rc.9

------------------------------------------------------------------------

## Installation

``` bash
npm install @nexuo/core
```

------------------------------------------------------------------------

## Quick Start

### Initialization

``` js
const { ButtonCreate } = require('@nexuo/core')
const makeWASocket = require('baileys')

const client = makeWASocket({})

ButtonCreate(client)
```

------------------------------------------------------------------------

### Handling Button Responses

Place `ButtonResponse` after `smsg` and before your main handler.

``` js
const { ButtonResponse } = require('@nexuo/core')

sock.ev.on('messages.upsert', async (chatUpdate) => {
  const mek = chatUpdate.messages[0]
  if (!mek.message) return

  const m = smsg(client, mek, {})

  ButtonResponse(m)

  require('./XEoms')(client, m, chatUpdate)
})
```

All button and list replies will automatically normalize into `m.text`.

------------------------------------------------------------------------

## Usage Examples

### Basic Menu

``` js
client.sendButton(m.chat, {
  text: 'Please choose a menu below',
  footer: 'Bot Menu',
  buttons: [
    { buttonName: 'Main Menu', id: 'menu' },
    { buttonName: 'Owner', id: 'owner' },
    { buttonName: 'Website', url: 'https://example.com' }
  ]
})
```

------------------------------------------------------------------------

### Information Message

``` js
client.sendButton(m.chat, {
  title: 'BOT INFORMATION',
  subtitle: 'System Update',
  text: 'The bot is running normally and ready to use.',
  footer: 'Bot Notification',
  buttons: [
    { buttonName: 'Check Status', id: 'status' }
  ]
}, { quoted: m })
```

------------------------------------------------------------------------

### With Mention

``` js
client.sendButton(m.chat, {
  text: `Hello @${m.sender.split('@')[0]}, select the feature you want to use.`,
  footer: 'Main Menu',
  buttons: [
    { buttonName: 'Profile', id: 'profile' }
  ],
  mentions: [m.sender]
}, { quoted: m })
```

------------------------------------------------------------------------

### Promotional Message

``` js
client.sendButton(m.chat, {
  text: 'Special promotion available this week.',
  footer: 'Limited Offer',
  buttons: [
    { buttonName: 'Order Now', url: 'https://shop.com' }
  ],
  contextInfo: {
    externalAdReply: {
      title: 'WEEKLY PROMO',
      body: 'Limited time discount',
      thumbnailUrl: 'https://example.com/image.jpg',
      sourceUrl: 'https://example.com',
      mediaType: 1,
      renderLargerThumbnail: true
    }
  }
}, { quoted: m })
```

------------------------------------------------------------------------

### Category List Menu

``` js
client.sendButton(m.chat, {
  text: 'Select a category below',
  buttons: [
    {
      buttonName: 'Food Menu',
      title: 'Food Category',
      rows: [
        { title: 'Main Course', description: 'Rice, noodles, etc.', id: 'main_course' }
      ]
    },
    {
      buttonName: 'Drink Menu',
      title: 'Drink Category',
      rows: [
        { title: 'Hot Drinks', description: 'Coffee, tea', id: 'hot_drinks' }
      ]
    }
  ]
}, { quoted: m })
```

------------------------------------------------------------------------

## API Reference

### ButtonCreate(client, options)

  Parameter   Type     Required   Description
  ----------- -------- ---------- -------------------------
  client      object   Yes        Baileys socket instance
  options     object   No         Custom configuration

------------------------------------------------------------------------

### ButtonResponse(message)

  Parameter   Type     Required   Description
  ----------- -------- ---------- ------------------------
  message     object   Yes        Baileys message object

------------------------------------------------------------------------

### client.sendButton(jid, content, options)

  Parameter   Type               Required   Description
  ----------- ------------------ ---------- ----------------------------
  jid         string             Yes        Target chat ID
  content     object \| string   Yes        Message content
  options     object             No         Additional Baileys options

------------------------------------------------------------------------

## License

MIT

------------------------------------------------------------------------

## Contributing

Contributions are welcome.\
Please open an issue or submit a pull request.