Spaces:
Paused
Paused
πππππππ πππππππ β‘
commited on
Create buttons.js
Browse files- plugins/buttons.js +41 -0
plugins/buttons.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
const { Buttons, List } = require('whatsapp-web.js');
|
| 5 |
+
|
| 6 |
+
const cmd = {
|
| 7 |
+
pattern: 'testbuttons',
|
| 8 |
+
desc: 'Test WhatsApp buttons',
|
| 9 |
+
category: 'test',
|
| 10 |
+
filename: __filename
|
| 11 |
+
};
|
| 12 |
+
|
| 13 |
+
cmd.command = async (m, client) => {
|
| 14 |
+
const button = new Buttons('Button Test', [
|
| 15 |
+
{ buttonId: 'id1', buttonText: { displayText: 'Button 1' }, type: 1 },
|
| 16 |
+
{ buttonId: 'id2', buttonText: { displayText: 'Button 2' }, type: 1 }
|
| 17 |
+
], 'Button Body', 'footer');
|
| 18 |
+
|
| 19 |
+
client.sendMessage(m.from, button)
|
| 20 |
+
.then((res) => {
|
| 21 |
+
console.log('Button sent:', res);
|
| 22 |
+
})
|
| 23 |
+
.catch((err) => {
|
| 24 |
+
console.error('Error sending button:', err);
|
| 25 |
+
});
|
| 26 |
+
|
| 27 |
+
const list = new List('List Test', 'List Body', 'footer', [
|
| 28 |
+
{ title: 'Option 1', description: 'Description 1' },
|
| 29 |
+
{ title: 'Option 2', description: 'Description 2' }
|
| 30 |
+
], 'listSelectionText');
|
| 31 |
+
|
| 32 |
+
client.sendMessage(m.from, list)
|
| 33 |
+
.then((res) => {
|
| 34 |
+
console.log('List sent:', res);
|
| 35 |
+
})
|
| 36 |
+
.catch((err) => {
|
| 37 |
+
console.error('Error sending list:', err);
|
| 38 |
+
});
|
| 39 |
+
};
|
| 40 |
+
|
| 41 |
+
module.exports = cmd;
|