MCPcopy Create free account
hub / github.com/GlobalTechInfo/MEGA-MD / handler

Function handler

plugins/joke.js:8–24  ·  view source on GitHub ↗
(sock, message, args, context)

Source from the content-addressed store, hash-verified

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};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected