Skip to content

TextMessage Builder

TextMessage constructs formatted text message payloads with link preview controls, ad-reply headers, mentions, and quotes.


Basic Usage

javascript
import { TextMessage } from 'leaves-guardian';

const textMsg = new TextMessage()
  .setBody('Hello {{user}}, welcome to Leaves Guardian!')
  .setVars({ user: 'Rafa' });

await client.sendMessage(msg.chat.id, textMsg);

Methods

MethodDescription
.setBody(text)Sets the primary text message body (supports templating).
.disableLinkPreview()Disables automatic URL preview cards if the text contains hyperlinks.
.mention(jids)Adds JID(s) to the mention list.
.quote(msg)Attaches a quoted reply context.
.setAdReply(opts)Attaches rich external ad preview context.
.setChannelForward(opts)Attaches channel forwarding context.
.build()Compiles and returns the raw Baileys message object.
.send(jid, options)Dispatches the message directly.

javascript
const textMsg = new TextMessage()
  .setBody('Check out our official documentation at https://leaves-guardian.dev')
  .setAdReply({
    title: 'Leaves Guardian Documentation',
    body: 'Enterprise Baileys Wrapper & Infrastructure Library',
    thumbnailUrl: 'https://example.com/thumb.jpg',
    sourceUrl: 'https://leaves-guardian.dev'
  });

await client.sendMessage(msg.chat.id, textMsg);

Released under the MIT License.