𝐃𝐀𝐑𝐑𝐄𝐋𝐋 πŒπ”π‚π‡π„π‘πˆ ⚑ commited on
Commit
8cc06be
Β·
unverified Β·
1 Parent(s): 279efe6

Update buttons.js

Browse files
Files changed (1) hide show
  1. plugins/buttons.js +51 -38
plugins/buttons.js CHANGED
@@ -1,41 +1,54 @@
 
 
 
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;
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const config = require('../config');
2
+ const { cmd, commands } = require('../command');
3
+ const { fetchJson } = require('../lib/functions');
4
 
5
 
6
+ cmd({
7
+ pattern: "testbutton",
8
+ alias: [],
9
+ react: "🏈",
10
+ desc: "Test buttons",
11
+ category: "test",
 
12
  filename: __filename
13
+ }, async (conn, mek, m, {
14
+ from,
15
+ quoted,
16
+ body,
17
+ isCmd,
18
+ command,
19
+ args,
20
+ q,
21
+ isGroup,
22
+ sender,
23
+ senderNumber,
24
+ botNumber2,
25
+ botNumber,
26
+ pushname,
27
+ isMe,
28
+ isOwner,
29
+ groupName,
30
+ participants,
31
+ groupAdmins,
32
+ isBotAdmins,
33
+ isAdmins,
34
+ reply
35
+ }) => {
36
+ try {
37
+ const buttons = [
38
+ { buttonId: 'id1', buttonText: { displayText: 'Button 1' }, type: 1 },
39
+ { buttonId: 'id2', buttonText: { displayText: 'Button 2' }, type: 1 }
40
+ ];
41
+
42
+ const buttonMessage = {
43
+ text: "Test buttons",
44
+ footer: "Button footer",
45
+ buttons: buttons,
46
+ headerType: 1
47
+ };
48
+
49
+ await reply(buttonMessage);
50
+ } catch (error) {
51
+ console.error(error);
52
+ reply(`An error occurred: ${error.message}`);
53
+ }
54
+ });