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

Function handler

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

fetchWithRetriesFunction · 0.85

Tested by

no test coverage detected