This package creates embeds and buttons in a very simple way using the whatsapp-web.js module for whatsapp

Overview

Npm package version Npm package weekly downloads GitHub stars

This package creates embeds and buttons in a very simple way using the whatsapp-web.js module for whatsapp.

NOTE : Internally whatsapp-web.js is being used to send and receive messages. Though it has been safe as per my testing, I cannot promise that your number will not be blocked by Whatsapp. Also, this project is not affiliated, associated, authorized or endorsed with Whatsapp or any of its subsidiaries or affiliates in any way.


🔗 Links


🚀 Installation:

Install the package @deathabyss/wwebjs-sender with npm or yarn

npm

npm i @deathabyss/wwebjs-sender

yarn

yarn add @deathabyss/wwebjs-sender


Install the package whatsapp-web.js with npm or yarn

npm

npm i whatsapp-web.js

yarn

yarn add whatsapp-web.js


Features:

  • Create embeds in an easy way
  • Create buttons in an easy way
  • Reply to messages with embed
  • Send messages to a number with embeds and buttons at the same time in an easy way

👀 Example usage:

{ console.log("QR RECEIVED", qr); }); client.on("ready", () => { console.log("Client is ready!"); }); client.on("message", (msg) => { if (msg.body == "!command") { const { from } = msg; let embed = new WwebjsSender.MessageEmbed() .setTitle("✅ | Successful process!") .setDescription( "The process has been successful! To confirm press *Yes* or press *No* to cancel." ) .setFooter("WwebjsSender") .setTimestamp(); let button1 = new WwebjsSender.MessageButton() .setCustomId("yes") .setLabel("Yes"); let button2 = new WwebjsSender.MessageButton() .setCustomId("no") .setLabel("No"); WwebjsSender.send({ client: client, number: from, embed: embed, button: [button1, button2], }); } }); client.initialize();">
const WwebjsSender = require("@deathabyss/wwebjs-sender");
const { Client } = require("whatsapp-web.js");

const client = new Client();

client.on("qr", (qr) => {
  console.log("QR RECEIVED", qr);
});

client.on("ready", () => {
  console.log("Client is ready!");
});

client.on("message", (msg) => {
  if (msg.body == "!command") {
    const { from } = msg;
    let embed = new WwebjsSender.MessageEmbed()
      .setTitle("✅ | Successful process!")
      .setDescription(
        "The process has been successful! To confirm press *Yes* or press *No* to cancel."
      )
      .setFooter("WwebjsSender")
      .setTimestamp();

    let button1 = new WwebjsSender.MessageButton()
      .setCustomId("yes")
      .setLabel("Yes");

    let button2 = new WwebjsSender.MessageButton()
      .setCustomId("no")
      .setLabel("No");

    WwebjsSender.send({
      client: client,
      number: from,
      embed: embed,
      button: [button1, button2],
    });
  }
});

client.initialize();

👀 Example Result:


📚 Usage:

MessageEmbed

let embed = new MessageEmbed() //Call the constructor MessageEmbed
  .setTitle("Title") //Set a title for the embed [optional]
  .setDescription("Description") //Set a description for the embed [required]
  .setFooter("Footer") //Set a footer for the embed [optional]
  .setTimestamp(); //Set a timestamp for the embed [optional]

MessageButton

let button = new MessageButton() //Call the constructor MessageButton
  .setCustomId("Id") //Set a custom id for the button [optional]
  .setLabel("Label"); //Set a label for the button [required]

Reply

reply({
  message: msg, //The message that was received [required]
  embed: embed, //The embed [required]
});

Send

send({
  client: client, //The client of the bot [required]
  number: number, //The number to send the message [required]
  embed: embed, //The embed [required]
  button: [button], //The button/s [optional]
});

📁 Contributing

1 - Fork it (https://github.com/yourname/yourproject/fork)

2 - Create your feature branch (git checkout -b features/thing)

3 - Commit your changes (git commit -am 'feat(image): Add some thing')

4 - Push to the branch (git push origin feature/thing)

5 - Create a new Pull Request


👥 Contributors


DeathAbyss

💻 🎨 🧪 🤔

📖 License

This project is licensed under the MIT License, see the LICENSE file for details.


You might also like...

Userland module that implements the module path mapping that Node.js does with "exports" in package.json

exports-map Userland module that implements the module path mapping that Node.js does with "exports" in package.json npm install exports-map Usage co

May 31, 2022

Package fetcher is a bot messenger which gather npm packages by uploading either a json file (package.json) or a picture representing package.json. To continue...

package-fetcher Ce projet contient un boilerplate pour un bot messenger et l'executable Windows ngrok qui va permettre de créer un tunnel https pour c

Mar 29, 2022

example app that creates a new player in Spotify Connect to play music from in the browse using Spotify Web Playback SDK.

Spotify Web Playback SDK Demo Requirements User must have Spotify Premium, DRM & EME supported and JavaScript enabled Web Browser. License Copyright 2

Jul 20, 2022

A simple site to generate useful resources for Gitpodification, including "open in gitpod" buttons and sample configuration scripts

Gitpodify A simple portal to generate "open in Gitpod" links Contributing There is a list of suggested repositories in app/routes/index.tsx. Feel free

Nov 7, 2022

🎨 Beautify your github profile with this amazing tool, creating the readme your way in a simple and fast way 🚀 The best profile readme generator you will find ⚡

🎨 Beautify your github profile with this amazing tool, creating the readme your way in a simple and fast way 🚀 The best profile readme generator you will find ⚡

Demo Profile Readme Generator The best profile readme generator you will find! About | Technologies | Requirements | Starting | Contributing 🎯 About

Jan 1, 2023

Creates Photoshop-like guides and rulers interface on a web page

Creates Photoshop-like guides and rulers interface on a web page

RulersGuides.js This Javascript package creates Photoshop-like guides and rulers interface on a web page. DEMO Main window: Menu: Guides are created b

Nov 27, 2022

Simple buttons you can use easily for your next project

Simple buttons you can use easily for your next project

Logo made by Harshit Sharma 💡 Simple buttons you can use easily for your next project. Contents Get started with sButtons Download CSS File CDN NPM U

Dec 15, 2022

Easy and simple way to share data via mobile’s built-in share module.

React-Mobile-Share Provides an easy and simple way to share data (such as text, url and media) via mobile’s built-in share module. It is based on Web

Dec 28, 2022
Comments
  • bug

    bug

    i se this , but nothing happends...

        case "test": {
          sendMessage(kevin, "Comando ejecutado");
          let embed = new WwebjsSender.MessageEmbed()
            .sizeEmbed(28)
            .setTitle("✅ | Successful process!")
            .setDescription("The process has been successful!")
            .addField("✔", "To confirm")
            .addField("❌", "To cancel")
            .addFields({
              name: "Now you have 2 buttons to choose!",
              value: "✔ or ❌",
            })
            .setFooter("WwebjsSender")
            .setTimestamp();
    
          let button1 = new WwebjsSender.MessageButton()
            .setCustomId("confirm")
            .setLabel("✔");
    
          let button2 = new WwebjsSender.MessageButton()
            .setCustomId("cancel")
            .setLabel("❌");
    
          WwebjsSender.send({
            client: client,
            number: from,
            embed: embed,
            button: [button1, button2],
          });
          break;
        }
    
    opened by Askeshine 12
  • Button is not working

    Button is not working

    I have use same example code. if I have send message with button then not working. if I have remove button then send message

    let embed = new WwebjsSender.MessageEmbed() .sizeEmbed(28) .setTitle("✅ | Successful process!") .setDescription("The process has been successful!") .addField("✔", "To confirm") .addField("❌", "To cancel") .addFields({ name: "Now you have 2 buttons to choose!", value: "✔ or ❌", }) .setFooter("WwebjsSender") .setTimestamp();

        let button1 = new WwebjsSender.MessageButton()
            .setCustomId("confirm")
            .setLabel("✔");
    
        let button2 = new WwebjsSender.MessageButton()
            .setCustomId("cancel")
            .setLabel("❌");
    
        WwebjsSender.send({
            client: client,
            number: from,
            embed: embed,
            button: [button1, button2],
        }); 
    
    opened by harshadkanziya-in 1
  •  TypeError: Cannot read properties of null (reading 'char')

    TypeError: Cannot read properties of null (reading 'char')

    Given Below Error image

    My Code Below `import { Client , LocalAuth,MessageMedia ,List} from 'whatsapp-web.js'//@ts-ignore import { MessageEmbed,MessageButton,send,Collector} from "@deathabyss/wwebjs-sender" import { readFileSync} from 'fs' import qrcode from 'qrcode-terminal'

    export const fileToBase64 = async( filepath:string) => { const buffedInput = "data:image/gif;base64," + await readFileSync(filepath, 'base64') return buffedInput }

    const client = new Client({ authStrategy: new LocalAuth(), puppeteer: { headless: false ,
    ignoreDefaultArgs: ['--disable-extensions'] } })

    client.on('qr', (qr) => { // Generate and scan this code with your phone console.log('QR RECEIVED') qrcode.generate(qr, {small: true}) });

    client.on('ready', () => { console.log('Client is ready!') })

    client.on('message', async(msg) => { if (msg.body == '!ping') { msg.reply('pong') } else if (msg.body == 'image'){ const base64Image = await readFileSync('./jagodasir.jpg',{encoding: 'base64'}) const media = new MessageMedia('image/png', base64Image) await msg.reply(media,msg.from,{caption: 'this is my caption'}) } else if (msg.body.startsWith('!send')){ const quoted_msg = await msg.getQuotedMessage() if (quoted_msg){ const command_and_number = msg.body.split(' ') const sanitized_number = command_and_number[1].toString().replace(/[- )(]/g, "") const final_number = 94${sanitized_number.substring(sanitized_number.length - 9)} const number_details = await client.getNumberId(final_number) if (number_details) { await quoted_msg.forward(number_details._serialized) //await foward_msg_return.ms } else { console.log(final_number, "\nMobile number is not registered"); } } else{ await msg.reply('Please Reply To A Message\n\n!send 771247221') }

    }
    else if (msg.body == 'list'){
        const productsList = new List(
            "Here's our list of products at 50% off",
            "View all products",
            [
              {
                title: "Products list",
                rows: [
                  { id: "apple", title: "Apple" },
                  { id: "mango", title: "Mango" },
                  { id: "banana", title: "Banana" },
                ],
              },
            ],
            "Please select a product"
          )
        await client.sendMessage(msg.from,productsList)
    }
    else if (msg.body == 'button'){
        let embed = new MessageEmbed()
            .sizeEmbed(28)
            .setTitle("✅ | Successful process!")
            .setDescription("The process has been successful!")
            .addField("✔", "To confirm")
            .addField("❌", "To cancel")
            .addFields({
                name: "Now you have 2 buttons to choose!",
                value: "✔ or ❌"
        }).setFooter("WwebjsSender").setTimestamp()
    
        let button1 = new MessageButton().setCustomId("confirm").setLabel("✔");
    
        let button2 = new MessageButton().setCustomId("cancel").setLabel("❌")
    
        await send({
            client: client,
            number: msg.from,
            embed: embed,
            button: [button1, button2]
        })
    }
    else if (msg.body == 'register'){
        let someEmbed = new MessageEmbed()
            .setTitle(`1️⃣ | What is your name?`)
            .setDescription(`Please, type your name.`)
            .setFooter(`Question!`)
            .setTimestamp()
            .sizeEmbed(24);
    
        let anotherEmbed = new MessageEmbed()
        .setTitle(`2️⃣ | What is your age?`)
        .setDescription(`Please, type your age.`)
        .setFooter(`Question!`)
        .setTimestamp()
        .sizeEmbed(24);
    
        let collect = new Collector({
            client: client,
            chat: await msg.getChat(),
            time: 10000,
            number: msg.from,
            max: [20, 3],
            question: ["🔐 What is your name?", "🚨 What is your age?"],
            embed: [someEmbed, anotherEmbed]
        })
        //@ts-ignore
        collect.on("message", async (msg) => {
        let body = msg.body;
        console.log(body);
        });
    
        await collect.initialize();
    
        let resultMessageQuestion = await collect.messageQuestionCollcetor();
    
        let resultEmbedQuestion = await collect.embedQuestionCollector();
    
        console.log(resultMessageQuestion, resultEmbedQuestion);
    }
    

    })

    client.initialize()`

    opened by NonameASecret 1
  • ReferenceError: id_btn is not defined

    ReferenceError: id_btn is not defined

    /app/node_modules/@deathabyss/wwebjs-sender/index.js:503
    id_btn = id;
           ^
    
    ReferenceError: id_btn is not defined
    at MessageButton.setCustomId (/app/node_modules/@deathabyss/wwebjs-sender/index.js:503:14)
    at Client.<anonymous> (/app/index.js:202:18)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    

    bug happens at .setCustomId("confirm")

    opened by leonimeloo 0
Owner
DeathAbyss
⬤▬▬▬▬▬▬⪨✬⪩▬▬▬▬▬▬⬤ • Owner【Troxx】 • Developer【Node/HTML】 • ‏‏‎Partner【@TwitchTheaterTv】 ⬤▬▬▬▬▬▬⪨✬⪩▬▬▬▬▬▬⬤
DeathAbyss
A MagicMirror² module which embeds multiple other websites with iframe or webview

MMM-EmbedURL This is a MagicMirror² module which embeds other websites either by "iframe" (default), "webview" or a custom HTML-element to your mirror

Thomas Hirschberger 6 Dec 18, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
A simple interface module that creates password-policy for your application.

This module is a simple alternate to creating complex native Regex, or tidious multidimensional checks on password-string to check required elements.

Snigdh Shourya 3 Oct 27, 2022
An Advanced Activity Command Using Discord-Together Package For Discord.jsv13 with buttons

Active An Advanced Activity Bot Using Discord-Together Package For Discord.jsv13 with buttons. Report Bug · Request Feature Usage. How to run the bot?

Hypwreck 11 Feb 15, 2022
Allow moving/copying/and creation embeds for blocks with drag-n-drop just like Logseq or Roam

Demo Features Drag-n-drop for list items in the same pane and between different panes 3 modes: move block, copy block, embed block Automatic reference

null 92 Dec 26, 2022
This is a simple Image popup Jquery plugin. With a very simple configuration, you can show a popup on your webpage. By the way, this plugin works after page load.

Jquery-SingleImagePopup This is a simple Image popup Jquery plugin. With a very simple configuration, you can show a popup on your webpage. By the way

Rajan Karmaker 1 Aug 22, 2022
An exercise in building a very minimal (and very stupid) in-memory SQL-like database for educational purposes.

Stupid Database This is an exercise in building a very minimal (and very stupid) in-memory SQL-like database for educational purposes. None of this co

Fabio Akita 196 Dec 20, 2022
A Very Good Documentation Site created by the Very Good Ventures Team 🦄

Very Good Docs Site Developed with ?? by Very Good Ventures ?? A Very Good Docs Site created by the Very Good Ventures Team. Generated by the Very Goo

Very Good Open Source 8 Nov 2, 2022