mcbe-portal
Version:
Connect bedrock servers together using mcbe-portal, manage your servers with ease.
43 lines (34 loc) • 1.15 kB
JavaScript
const readline = require("node:readline");
class CommandHandler {
constructor(text, portal) {
this.portal = portal;
this.prefix = portal.config.prefix;
this.handler(text);
}
handler(text) {
const args = text.slice(this.prefix.length).trim().split(/\s+/);
const command = args.shift().toLowerCase();
switch (text) {
case "reload":{
this.portal.deploy_scripts();
this.portal.broadcast_command("reload");
}
case "backup": return this.portal.backup_servers();
}
switch (command) {
case "reload":return this.portal.deploy_scripts();
case "backup": return this.portal.backup_servers();
case "restart": return this.portal.restart_servers();
default: return this.portal.broadcast_command(text);
}
}
}
module.exports = function (portal) {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.on("line", (input) => {
new CommandHandler(input, portal);
});
}