You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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'
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()`
The text was updated successfully, but these errors were encountered:
letsomeEmbed=newWwebjsSender.MessageEmbed().sizeEmbed(24).setTitle(`1️⃣ | What is your name?`).setDescription(`Please, type your name.`).setFooter(`Question!`).setTimestamp();letanotherEmbed=newWwebjsSender.MessageEmbed().sizeEmbed(24).setTitle(`2️⃣ | What is your age?`).setDescription(`Please, type your age.`).setFooter(`Question!`).setTimestamp();
The problem was in the README.md file, in the examples, it was already fixed in version 1.93.0, update your example code and package with NPM to use it.
Another thing, the buttons won't work unless you don't use multidevice something that can't anymore, so for now you won't be able to use the buttons, until whatsapp-web.js fixes the problem.
Given Below Error
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')
}
})
client.initialize()`
The text was updated successfully, but these errors were encountered: