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

Function handler

plugins/joke.ts:10–25  ·  view source on GitHub ↗
(sock: any, message: any, args: any, context: BotContext)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected