mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-14 10:44:55 -05:00
add serverinfo
yeah it is now finally added
This commit is contained in:
parent
f112be3efe
commit
62549de56c
1 changed files with 50 additions and 0 deletions
50
commands/serverinfo.js
Normal file
50
commands/serverinfo.js
Normal file
|
@ -0,0 +1,50 @@
|
|||
const os = require('os')
|
||||
const path = require('path')
|
||||
const fs = require('fs/promises')
|
||||
|
||||
// should i move this to util?
|
||||
async function getCpuModelName () {
|
||||
const cpuInfo = await fs.readFile('/proc/cpuinfo')
|
||||
const lines = cpuInfo.toString().split('\n')
|
||||
// among us way of doing it
|
||||
const modelName = lines.find((line) => line.startsWith('model name')).split('\t: ')
|
||||
return modelName[1]
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
name: 'serverinfo',
|
||||
alias: [],
|
||||
description: 'Shows the info about the server that is hosting the bot',
|
||||
trusted: 0,
|
||||
usage: '',
|
||||
execute: async function (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
const component = []
|
||||
component.push({ text: 'Hostname: ', color: 'gold' })
|
||||
component.push({ text: os.hostname(), color: 'aqua' })
|
||||
component.push('\n')
|
||||
component.push({ text: 'Working directory: ', color: 'gold' })
|
||||
component.push({ text: path.join(__dirname, '..') /* if without .. it will includes the commands directory */, color: 'aqua' })
|
||||
component.push('\n')
|
||||
component.push({ text: 'OS architecture: ', color: 'gold' })
|
||||
component.push({ text: os.arch(), color: 'aqua' })
|
||||
component.push('\n')
|
||||
component.push({ text: 'OS platform: ', color: 'gold' })
|
||||
component.push({ text: os.platform(), color: 'aqua' })
|
||||
component.push('\n')
|
||||
component.push({ text: 'OS name: ', color: 'gold' })
|
||||
component.push({ text: os.version(), color: 'aqua' })
|
||||
component.push('\n')
|
||||
component.push({ text: 'CPU cores: ', color: 'gold' })
|
||||
component.push({ text: os.cpus().length, color: 'aqua' })
|
||||
component.push('\n')
|
||||
component.push({ text: 'CPU model: ', color: 'gold' })
|
||||
component.push({ text: await getCpuModelName(), color: 'aqua' })
|
||||
component.push('\n')
|
||||
component.push({ text: 'Total memory usage: ', color: 'gold' })
|
||||
component.push({ text: `${Math.floor(os.totalmem() / 1024 / 1024)} MB`, color: 'aqua' })
|
||||
component.push('\n')
|
||||
component.push({ text: 'Available memory usage: ', color: 'gold' })
|
||||
component.push({ text: `${Math.floor(os.freemem() / 1024 / 1024)} MB`, color: 'aqua' })
|
||||
bot.tellraw(selector, component)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue