mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-20 12:39:20 +00:00
example update
This commit is contained in:
22
example.js
22
example.js
@@ -32,6 +32,12 @@ client.on('ready', () => {
|
|||||||
client.on('message', async msg => {
|
client.on('message', async msg => {
|
||||||
console.log('MESSAGE RECEIVED', msg);
|
console.log('MESSAGE RECEIVED', msg);
|
||||||
|
|
||||||
|
if (msg.selectedButtonId == 'test') {
|
||||||
|
return msg.reply('You clicked the button!');
|
||||||
|
} else if (msg.selectedRowId == 'test') {
|
||||||
|
return msg.reply('You clicked that section');
|
||||||
|
}
|
||||||
|
|
||||||
if (msg.body === '!ping reply') {
|
if (msg.body === '!ping reply') {
|
||||||
// Send a new message as a reply to the current one
|
// Send a new message as a reply to the current one
|
||||||
msg.reply('pong');
|
msg.reply('pong');
|
||||||
@@ -200,11 +206,19 @@ client.on('message', async msg => {
|
|||||||
);
|
);
|
||||||
client.sendMessage(msg.from, button);
|
client.sendMessage(msg.from, button);
|
||||||
} else if (msg.body === '!list') {
|
} else if (msg.body === '!list') {
|
||||||
let sections = [{title:'sectionTitle',rows:[{title:'ListItem1', description: 'desc'},{title: 'Try clicking me (id: test)', }]}];
|
let sections = [
|
||||||
let list = new List('List body','btnText',sections,'Title','footer');
|
{
|
||||||
client.sendMessage(msg.from, list);
|
title: 'Secton title',
|
||||||
|
rows: [
|
||||||
|
{title:'ListItem1', description: 'desc'},
|
||||||
|
{title: 'Try clicking me (id: test)', id: 'test'}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
let list = new List('List body', 'btnText', sections, 'Custom title', 'custom footer, google.com');
|
||||||
|
await client.sendMessage(msg.from, list);
|
||||||
} else if (msg.body === '!reaction') {
|
} else if (msg.body === '!reaction') {
|
||||||
msg.react('👍');
|
await msg.react('👍');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user