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

Function handler

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

Source from the content-addressed store, hash-verified

6 description: 'Get a random mountain image',
7 usage: '.mountain',
8 async handler(sock, message, args, context) {
9 const chatId = context.chatId || message.key.remoteJid;
10 try {
11 const res = await axios.get('https://raw.githubusercontent.com/GlobalTechInfo/Database/main/images/mountain.json');
12 if (!res.data || !Array.isArray(res.data) || res.data.length === 0) {
13 return await sock.sendMessage(chatId, { text: '❌ Failed to fetch image.' }, { quoted: message });
14 }
15 const randomImage = res.data[Math.floor(Math.random() * res.data.length)];
16 await sock.sendMessage(chatId, { image: { url: randomImage }, caption: '🏔️ Mountain Image' }, { quoted: message });
17 }
18 catch (err) {
19 console.error('Mountain image plugin error:', err);
20 await sock.sendMessage(chatId, { text: '❌ Error while fetching image.' }, { quoted: message });
21 }
22 }
23};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected