(sock, message, args, context)
| 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 | }; |
nothing calls this directly
no test coverage detected