发送按钮在 Whatsapp web js 中不起作用

问题描述 投票:0回答:2

出于某种原因它不想发送按钮,我在网上查找但没有找到帮助,这是我的代码:


const { Client, LocalAuth ,MessageMedia, Buttons } = require('whatsapp-web.js');

const client = new Client({
    authStrategy: new LocalAuth()
});

client.on('qr', qr => {
    qrcode.generate(qr, {small: true});
});

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


client.on('message', message => {
    console.log('message from', message.from)
    if (message.body === "!button") {

        let button = new Buttons('Button body',[{body:'bt1'},{body:'bt2'},{body:'bt3'}],'title','footer');
        client.sendMessage(message.from, button);

    }
});
 
client.initialize();
javascript node.js whatsapp
2个回答
5
投票

安装使用:

npm i github:pedroslopez/whatsapp-web.js#fix-buttons-list

yarn add github:pedroslopez/whatsapp-web.js#fix-buttons-list

0
投票

-从这里安装Git Bash。

-打开CMD,在项目目录下写:'npm install git+https://github.com/pedroslopez/whatsapp-web.js#fix-buttons-list'

定义模块时不要忘记调用“按钮”。 像这样:

const { Client, LocalAuth  ,Buttons,List,MessageMedia} = require('whatsapp-web.js');
© www.soinside.com 2019 - 2024. All rights reserved.