(sock, message, args, context)
| 6 | description: 'Get a random general joke', |
| 7 | usage: '.joke2', |
| 8 | async handler(sock, message, args, context) { |
| 9 | const chatId = context.chatId || message.key.remoteJid; |
| 10 | try { |
| 11 | const res = await axios.get('https://raw.githubusercontent.com/GlobalTechInfo/Database/main/text/random_jokes.txt'); |
| 12 | if (!res.data) { |
| 13 | return await sock.sendMessage(chatId, { text: '❌ Failed to fetch joke.' }, { quoted: message }); |
| 14 | } |
| 15 | const jokes = res.data.split('\n').filter((line) => line.trim() !== ''); |
| 16 | if (jokes.length === 0) { |
| 17 | return await sock.sendMessage(chatId, { text: '❌ No jokes available.' }, { quoted: message }); |
| 18 | } |
| 19 | const randomJoke = jokes[Math.floor(Math.random() * jokes.length)]; |
| 20 | await sock.sendMessage(chatId, { text: `😂 *Joke*\n\n${randomJoke}` }, { quoted: message }); |
| 21 | } |
| 22 | catch (err) { |
| 23 | console.error('Joke plugin error:', err); |
| 24 | await sock.sendMessage(chatId, { text: '❌ Error while fetching joke.' }, { quoted: message }); |
| 25 | } |
| 26 | } |
| 27 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected