Fix buttons list (#1649)

* DOCS: Buttons usage

* FIX: Limit buttons amount to avoid crashes

* STYLE: Fix for ESLINT test
This commit is contained in:
Sergio Carvalho
2022-08-14 16:12:01 -03:00
committed by GitHub
parent 627b245143
commit ef68f2f156
3 changed files with 276 additions and 56 deletions

View File

@@ -189,7 +189,20 @@ client.on('message', async msg => {
client.interface.openChatWindowAt(quotedMsg.id._serialized);
}
} else if (msg.body === '!buttons') {
let button = new Buttons('Button body',[{body:'bt1'},{body:'bt2'},{body:'bt3'}],'title','footer');
let button = new Buttons(
'Button body',
[
{ body: 'whatsapp-web.js', url: 'https://wwebjs.dev/' },
{ body: 'Call me', number: '+1 (805) 457-4992' },
{ body: 'third special button', number: '+1 (202) 968-6161' },// Limited to 2 especial buttons, this one will be ignored
{ body: 'Some text' },
{ body: 'Another text' },
{ body: 'Another another text' },
{ body: 'Fourth button' }// Limited to 3 regular buttons, this one will be ignored
],
'title',
'footer'
);
client.sendMessage(msg.from, button);
} else if (msg.body === '!list') {
let sections = [{title:'sectionTitle',rows:[{title:'ListItem1', description: 'desc'},{title:'ListItem2'}]}];