| 5 | |
| 6 | |
| 7 | async 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 | |
| 33 | module.exports = githubCommand; |