(sock, message, args, context)
| 5 | description: 'Ask the magic 8-ball a question', |
| 6 | usage: '.8ball Will I be rich?', |
| 7 | async handler(sock, message, args, context) { |
| 8 | const chatId = context.chatId || message.key.remoteJid; |
| 9 | try { |
| 10 | const question = args.join(' '); |
| 11 | if (!question) { |
| 12 | await sock.sendMessage(chatId, { |
| 13 | text: '🎱 Please ask a question!' |
| 14 | }, { quoted: message }); |
| 15 | return; |
| 16 | } |
| 17 | const eightBallResponses = [ |
| 18 | "Yes, definitely!", |
| 19 | "No way!", |
| 20 | "Ask again later.", |
| 21 | "It is certain.", |
| 22 | "Very doubtful.", |
| 23 | "Without a doubt.", |
| 24 | "My reply is no.", |
| 25 | "Signs point to yes." |
| 26 | ]; |
| 27 | const randomResponse = eightBallResponses[Math.floor(Math.random() * eightBallResponses.length)]; |
| 28 | await sock.sendMessage(chatId, { |
| 29 | text: `🎱 *Question:* ${question}\n\n*Answer:* ${randomResponse}` |
| 30 | }, { quoted: message }); |
| 31 | } |
| 32 | catch (error) { |
| 33 | console.error('Error in 8ball command:', error); |
| 34 | await sock.sendMessage(chatId, { |
| 35 | text: '❌ Something went wrong with the magic 8-ball!' |
| 36 | }, { quoted: message }); |
| 37 | } |
| 38 | } |
| 39 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected