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

Function handler

plugins/pies.js:19–47  ·  view source on GitHub ↗
(sock, message, args, context)

Source from the content-addressed store, hash-verified

17 description: 'Get a pies image from a specific country',
18 usage: `.pies <country>\nAvailable countries: ${VALID_COUNTRIES.join(', ')}`,
19 async handler(sock, message, args, context) {
20 const chatId = context.chatId || message.key.remoteJid;
21 const sub = (args[0] || '').toLowerCase();
22 if (!sub) {
23 await sock.sendMessage(chatId, {
24 text: `Usage: .pies <country>\nCountries: ${VALID_COUNTRIES.join(', ')}`
25 }, { quoted: message });
26 return;
27 }
28 if (!VALID_COUNTRIES.includes(sub)) {
29 await sock.sendMessage(chatId, {
30 text: `Unsupported country: ${sub}. Try one of: ${VALID_COUNTRIES.join(', ')}`
31 }, { quoted: message });
32 return;
33 }
34 try {
35 const imageBuffer = await fetchPiesImageBuffer(sub);
36 await sock.sendMessage(chatId, {
37 image: imageBuffer,
38 caption: `🍰 pies: ${sub}`
39 }, { quoted: message });
40 }
41 catch (err) {
42 console.error('Pies Command Error:', err);
43 await sock.sendMessage(chatId, {
44 text: '❌ Failed to fetch image. Please try again.'
45 }, { quoted: message });
46 }
47 }
48};

Callers

nothing calls this directly

Calls 1

fetchPiesImageBufferFunction · 0.85

Tested by

no test coverage detected