(sock, message, args, context)
| 22 | description: 'Get a random “why” question from the API', |
| 23 | usage: '.why', |
| 24 | async handler(sock, message, args, context) { |
| 25 | const chatId = context.chatId || message.key.remoteJid; |
| 26 | try { |
| 27 | const data = await fetchWithRetries('https://nekos.life/api/v2/why'); |
| 28 | if (!data?.why?.trim()) { |
| 29 | return await sock.sendMessage(chatId, { text: '❌ Invalid response from API. Try again.' }, { quoted: message }); |
| 30 | } |
| 31 | await sock.sendMessage(chatId, { text: `🤔 *Why?*\n\n${data.why}` }, { quoted: message }); |
| 32 | } |
| 33 | catch (error) { |
| 34 | console.error('Why plugin error:', error); |
| 35 | await sock.sendMessage(chatId, { text: '❌ Failed to fetch question. Try again later.' }, { quoted: message }); |
| 36 | } |
| 37 | } |
| 38 | }; |
nothing calls this directly
no test coverage detected