const { Client, LocalAuth, MessageMedia, Buttons } = require('whatsapp-web.js');
const qrcode = require('qrcode-terminal')
const axios = require('axios');
const images = require('./data')
const fs = require('fs');
const WwebjsSender = require('@deathabyss/wwebjs-sender')
const quotes = {
method: 'GET',
url: 'https://type.fit/api/quotes'
};
const client = new Client({
authStrategy: new LocalAuth(),
});
client.on('qr', (qr) => {
qrcode.generate(qr, { small: true })
});
client.on('authenticated', () => {
console.log('Authenticated');
});
let chatId = ""
client.on('message', message => {
console.log(message.body);
chatId = message.from;
console.log(chatId);
});
//buttons
client.on("message", (msg) => {
if (msg.body == "!command") {
const from = chatId
console.log(from);
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",
value: "✔ or ❌",
})
.setFooter('WwebjsSender')
.setTimestamp();
let button1 = new WwebjsSender.MessageButton()
.setCustomId("confirm")
.setLabel("✔")
let button2 = new WwebjsSender.MessageButton()
.setCustomId("cancel")
.setLabel("❌");
try {
WwebjsSender.send({
client: client,
number: from,
embed: embed,
button: [button1, button2]
});
} catch (error) {
console.log(error);
}
}
});
//Listen for incoming messages
client.on('ready', () => {
console.log("Client is ready");
});
client.initialize();
I am building a bot using whatsapp-web.js. I want to send send buttons as replies.
I made confirm that I am authenticated. I tried many ways to get buttons as replies but none of them is working.
I am using @deathabyss/wwebjs-sender to get buttons in the bot.
But I am not getting any replies or errors.
Show me a way to send buttons as replies in whatsapp-web.js?