Advertisement
Jshep89

Untitled

Sep 15th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ======================
  2. // Current proccess info
  3. // ======================
  4.  
  5. exports.proc = function(data)
  6. {
  7.    if (data.message.author.id !== data.config.owner)
  8.    {
  9.       return;
  10.    }
  11.  
  12.    //
  13.    // Get proccess data
  14.    //
  15.  
  16.    const title = `**\`${process.title}\`** `;
  17.    const pid = `**\`#${process.pid}\`** `;
  18.    const platform = `**\`${process.platform}\`** `;
  19.  
  20.    //
  21.    // Get shard info
  22.    //
  23.  
  24.    let shard = data.message.client.shard;
  25.  
  26.    if (!shard)
  27.    {
  28.       shard = {
  29.          id: 0,
  30.          count: 1
  31.       };
  32.    }
  33.  
  34.    //
  35.    // Byte formatter (mb/gb)
  36.    //
  37.  
  38.    const byteFormat = function(bytes)
  39.    {
  40.       if (bytes > 750000000)
  41.       {
  42.          const gb = bytes / 1000 / 1000 / 1000;
  43.          return gb.toFixed(3) + " gb";
  44.       }
  45.  
  46.       const mb = bytes / 1000 / 1000;
  47.       return mb.toFixed(2) + " mb";
  48.    };
  49.  
  50.    //
  51.    // Get memory usage
  52.    //
  53.  
  54.    const memory = process.memoryUsage();
  55.    const memoryFormat = oneLine`
  56.       **\`${byteFormat(memory.rss)}\`** \`rss\` ยท
  57.       **\`${byteFormat(memory.heapUsed)}\`**\`/\`
  58.       **\`${byteFormat(memory.heapTotal)}\`** \`heap\` ยท
  59.       **\`${byteFormat(memory.external)}\`** \`external\`
  60.    `;
  61.  
  62.    //
  63.    // Get CPU usage
  64.    //
  65.  
  66.    const cpu = process.cpuUsage();
  67.  
  68.    //
  69.    // Get proccess/shard uptime
  70.    //
  71.  
  72.    const procUptime = secConverter(Math.round(process.uptime()), "sec");
  73.  
  74.    const shardUptime = secConverter(data.message.client.uptime);
  75.  
  76.    const uptimeFormat = function(uptime)
  77.    {
  78.       return oneLine`
  79.          **\`${uptime.days}\`** days
  80.          **\`${uptime.hours}:${uptime.minutes}:${uptime.seconds}\`**
  81.       `;
  82.    };
  83.  
  84.    //
  85.    // Render message
  86.    //
  87.  
  88.    data.text = stripIndent`
  89.       :robot:  Process:  ${title + pid + platform}
  90.  
  91.       :control_knobs:  RAM:  ${memoryFormat}
  92.  
  93.       :control_knobs:  CPU:  **\`${cpu}%\`**
  94.  
  95.       :stopwatch:  Proc Uptime:  ${uptimeFormat(procUptime)}
  96.  
  97.       :stopwatch:  Shard Uptime:  ${uptimeFormat(shardUptime)}
  98.  
  99.       :pager:  Current Shard:  **\`${shard.id + 1} / ${shard.count}\`**
  100.    `;
  101.  
  102.    //
  103.    // Send message
  104.    //
  105.  
  106.    botSend(data);
  107. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement