(sock, message, args, context)
| 6 | description: 'Get a random dad joke', |
| 7 | usage: '.joke', |
| 8 | async handler(sock, message, args, context) { |
| 9 | const chatId = context.chatId || message.key.remoteJid; |
| 10 | try { |
| 11 | const response = await axios.get('https://icanhazdadjoke.com/', { |
| 12 | headers: { Accept: 'application/json' } |
| 13 | }); |
| 14 | const joke = response.data.joke; |
| 15 | await sock.sendMessage(chatId, { text: `😂 ${joke}` }, { quoted: message }); |
| 16 | } |
| 17 | catch (error) { |
| 18 | console.error('Error fetching dad joke:', error); |
| 19 | await sock.sendMessage(chatId, { |
| 20 | text: 'Sorry, I could not fetch a joke right now. Please try again later.', |
| 21 | quoted: message |
| 22 | }); |
| 23 | } |
| 24 | } |
| 25 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected