(sock, message, args, context)
| 6 | description: 'Get information about a chemical element', |
| 7 | usage: '.element <name or symbol>', |
| 8 | async handler(sock, message, args, context) { |
| 9 | const chatId = context.chatId || message.key.remoteJid; |
| 10 | const query = args?.join(' ')?.trim(); |
| 11 | if (!query) { |
| 12 | return await sock.sendMessage(chatId, { text: '*Provide element name or symbol.*\nExample: .element H' }, { quoted: message }); |
| 13 | } |
| 14 | try { |
| 15 | const { data: json } = await axios.get(`https://api.popcat.xyz/periodic-table?element=${encodeURIComponent(query)}`); |
| 16 | if (!json?.name) { |
| 17 | return await sock.sendMessage(chatId, { text: '❌ Element not found.' }, { quoted: message }); |
| 18 | } |
| 19 | const text = `🧪 *Element Info*\n` + |
| 20 | `• Name: ${json.name}\n` + |
| 21 | `• Symbol: ${json.symbol}\n` + |
| 22 | `• Atomic #: ${json.atomic_number}\n` + |
| 23 | `• Atomic Mass: ${json.atomic_mass}\n` + |
| 24 | `• Period: ${json.period}\n` + |
| 25 | `• Phase: ${json.phase}\n` + |
| 26 | `• Discovered By: ${json.discovered_by || 'Unknown'}\n\n` + |
| 27 | `📘 Summary:\n${json.summary}`; |
| 28 | await sock.sendMessage(chatId, { image: { url: json.image }, caption: text }, { quoted: message }); |
| 29 | } |
| 30 | catch (error) { |
| 31 | console.error('Element plugin error:', error); |
| 32 | await sock.sendMessage(chatId, { text: '❌ Failed to fetch element info.' }, { quoted: message }); |
| 33 | } |
| 34 | } |
| 35 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected