(sock, chatId, message, args)
| 13 | } |
| 14 | |
| 15 | async function piesCommand(sock, chatId, message, args) { |
| 16 | const sub = (args && args[0] ? args[0] : '').toLowerCase(); |
| 17 | if (!sub) { |
| 18 | await sock.sendMessage(chatId, { text: `Usage: .pies <country>\nCountries: ${VALID_COUNTRIES.join(', ')}` }, { quoted: message }); |
| 19 | return; |
| 20 | } |
| 21 | if (!VALID_COUNTRIES.includes(sub)) { |
| 22 | await sock.sendMessage(chatId, { text: `❌ Unsupported country: ${sub}. Try one of: ${VALID_COUNTRIES.join(', ')}` }, { quoted: message }); |
| 23 | return; |
| 24 | } |
| 25 | try { |
| 26 | const imageBuffer = await fetchPiesImageBuffer(sub); |
| 27 | await sock.sendMessage( |
| 28 | chatId, |
| 29 | { image: imageBuffer, caption: `pies: ${sub}` }, |
| 30 | { quoted: message } |
| 31 | ); |
| 32 | } catch (err) { |
| 33 | console.error('Error in pies command:', err); |
| 34 | await sock.sendMessage(chatId, { text: '❌ Failed to fetch image. Please try again.' }, { quoted: message }); |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | async function piesAlias(sock, chatId, message, country) { |
| 39 | try { |
nothing calls this directly
no test coverage detected