This repository has been archived on 2023-01-01. You can view files and clone it, but cannot push or open issues or pull requests.
kaboomproxy/commands/reloadall.js
2021-06-17 02:08:50 -03:00

25 lines
No EOL
719 B
JavaScript

const fs = require("fs");
module.exports.exec = function(vanillaclient, client, server, args) {
vanillaclient.chat("Reloading...");
let start = new Date();
/* deinject all modules */
for(let module of client.modules) {
module.uninject(vanillaclient, client, server);
}
/* clear cache */
for(let path of Object.keys(require.cache)) {
if(path.includes("node_modules") || !path.includes(".js")) continue;
delete require.cache[path];
}
/* inject all modules */
client.modules = [];
client.injectModules();
let end = new Date();
vanillaclient.chat(`Done! Took ${end - start}ms. Memory usage: ${process.memoryUsage().heapUsed/1000}KB`);
};