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