node js check ram usage code example

Example 1: process memory usage javascript

const arr = [1, 2, 3, 4, 5, 6, 9, 7, 8, 9, 10];
arr.reverse();
const used = process.memoryUsage().heapUsed / 1024 / 1024;
console.log(`The script uses approximately ${Math.round(used * 100) / 100} MB`);

Example 2: node js check ram usage

const Discord = require('discord.js');
const client = new Discord.Client();
const config = require("./config.json")




client.on("ready", () => {
    console.log(`Bot Foi Iniciado, com ${client.users.cache.size} usuários, em ${client.channels.cache.size} canais, em ${client.guilds.cache.size} servidores.`);
    client.user.setActivity(`Dinheiro Na Putaria`);
    client.user.setUsername('Hidrz')
});
const prefix = "!";

client.on("message", async message => {

    if (message.author.bot) return;
    if (message.channel.type == 'dm') return;
    if (!message.guild) return;
    if (!message.content.toLowerCase().startsWith(config.prefix.toLowerCase())) return;
    if (message.content.startsWith(`<@!${client.user.id}>`) || message.content.startsWith(`<@${client.user.id}>`)) return;

   const args = message.content
       .trim().slice(config.prefix.length)
       .split(/ +/g);
   const command = args.shift().toLowerCase();

   try {
       const commandFile = require(`./commands/${command}.js`)
       commandFile.run(client, message, args);
   } catch (err) {
   console.error('Erro:' + err);
   }
    
   
    

    
});
   



client.login(config.token)

Example 3: node js check ram usage

const Discord = require('discord.js');
const client = new Discord.Client();
const config = require("./config.json")




client.on("ready", () => {
    console.log(`Bot Foi Iniciado, com ${client.users.cache.size} usuários, em ${client.channels.cache.size} canais, em ${client.guilds.cache.size} servidores.`);
    client.user.setActivity(`Dinheiro Na Putaria`);
    client.user.setUsername('Hidrz')
});
const prefix = "!";

client.on("message", async message => {

    if (message.author.bot) return;
    if (message.channel.type == 'dm') return;
    if (!message.guild) return;
    if (!message.content.toLowerCase().startsWith(config.prefix.toLowerCase())) return;
    if (message.content.startsWith(`<@!${client.user.id}>`) || message.content.startsWith(`<@${client.user.id}>`)) return;

   const args = message.content
       .trim().slice(config.prefix.length)
       .split(/ +/g);
   const command = args.shift().toLowerCase();

   try {
       const commandFile = require(`./commands/${command}.js`)
       commandFile.run(client, message, args);
   } catch (err) {
   console.error('Erro:' + err);
   }
    
   
    

    
});
   



client.login(config.token)

Tags:

Misc Example