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

Function handler

plugins/goodnight.js:7–23  ·  view source on GitHub ↗
(sock, message, args, context)

Source from the content-addressed store, hash-verified

5 description: 'Send a random good night message',
6 usage: '.goodnight',
7 async handler(sock, message, args, context) {
8 const chatId = context.chatId || message.key.remoteJid;
9 try {
10 const shizokeys = 'shizo';
11 const res = await fetch(`https://shizoapi.onrender.com/api/texts/lovenight?apikey=${shizokeys}`);
12 if (!res.ok) {
13 throw new Error(await res.text());
14 }
15 const json = await res.json();
16 const goodnightMessage = json.result;
17 await sock.sendMessage(chatId, { text: goodnightMessage }, { quoted: message });
18 }
19 catch (error) {
20 console.error('Goodnight plugin error:', error);
21 await sock.sendMessage(chatId, { text: '❌ Failed to get goodnight message. Please try again later!' }, { quoted: message });
22 }
23 }
24};

Callers

nothing calls this directly

Calls 1

jsonMethod · 0.80

Tested by

no test coverage detected