MCPcopy Create free account
hub / github.com/mruniquehacker/Knightbot-MD / githubCommand

Function githubCommand

commands/github.js:7–31  ·  view source on GitHub ↗
(sock, chatId, message)

Source from the content-addressed store, hash-verified

5
6
7async function githubCommand(sock, chatId, message) {
8 try {
9 const res = await fetch('https://api.github.com/repos/mruniquehacker/Knightbot-md');
10 if (!res.ok) throw new Error('Error fetching repository data');
11 const json = await res.json();
12
13 let txt = `*乂 Knight Bot MD 乂*\n\n`;
14 txt += `✩ *Name* : ${json.name}\n`;
15 txt += `✩ *Watchers* : ${json.watchers_count}\n`;
16 txt += `✩ *Size* : ${(json.size / 1024).toFixed(2)} MB\n`;
17 txt += `✩ *Last Updated* : ${moment(json.updated_at).format('DD/MM/YY - HH:mm:ss')}\n`;
18 txt += `✩ *URL* : ${json.html_url}\n`;
19 txt += `✩ *Forks* : ${json.forks_count}\n`;
20 txt += `✩ *Stars* : ${json.stargazers_count}\n\n`;
21 txt += `💥 *KnightBot MD*`;
22
23 // Use the local asset image
24 const imgPath = path.join(__dirname, '../assets/bot_image.jpg');
25 const imgBuffer = fs.readFileSync(imgPath);
26
27 await sock.sendMessage(chatId, { image: imgBuffer, caption: txt }, { quoted: message });
28 } catch (error) {
29 await sock.sendMessage(chatId, { text: '❌ Error fetching repository information.' }, { quoted: message });
30 }
31}
32
33module.exports = githubCommand;

Callers 1

handleMessagesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected