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

Function handler

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

Source from the content-addressed store, hash-verified

6 description: 'Get a Would You Rather question',
7 usage: '.wyr',
8 async handler(sock, message, args, context) {
9 const chatId = context.chatId || message.key.remoteJid;
10 try {
11 const res = await axios.get('https://discardapi.dpdns.org/api/quote/wyr?apikey=guru');
12 if (!res.data || res.data.status !== true) {
13 return await sock.sendMessage(chatId, { text: '❌ Failed to fetch question.' }, { quoted: message });
14 }
15 const opt1 = res.data.question?.option1 || 'Option 1 not found';
16 const opt2 = res.data.question?.option2 || 'Option 2 not found';
17 const _creator = res.data.creator || 'Unknown';
18 const replyText = `🤔 *Would You Rather*\n\n◍ ${opt1}\n◍ ${opt2}`;
19 await sock.sendMessage(chatId, { text: replyText }, { quoted: message });
20 }
21 catch (err) {
22 console.error('WYR plugin error:', err);
23 await sock.sendMessage(chatId, { text: '❌ Error while fetching question.' }, { quoted: message });
24 }
25 }
26};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected