diff --git a/commands/moderation/ccash.js b/commands/moderation/ccash.js new file mode 100644 index 0000000..8427681 --- /dev/null +++ b/commands/moderation/ccash.js @@ -0,0 +1,43 @@ +const fs = require("fs"); +const got = require("got"); + +const { spawn } = require("child_process"); +let minecraftin; +module.exports = { + name: "ccash", + description: "start mc server", + guildOnly: true, + permissions: "KICK_MEMBERS", + async execute(message, args) { + let channel = message.guild.channels.cache.get(process.env.CCASHCHAN); + spawnMC(channel); + }, +}; + +function spawnMC(channel) { + let options = { + shell: true, + cwd: "/CCash/CCash/build", + }; + let arguments = message.content.split("!ccash "); + const ccash = spawn("./bank", [`${arguments[0]}`], options); + ccash.stdout.on("data", (data) => { + try { + channel.send(`${data}`); + } catch (err) { + console.log(err); + } + }); + + ccash.stderr.on("data", (data) => { + try { + channel.send(`${data}`); + } catch (err) { + console.log(err); + } + }); + + ccash.on("close", (code) => { + console.log(`child process exited with code ${code}`); + }); +} diff --git a/commands/moderation/stop.js b/commands/moderation/stop.js deleted file mode 100644 index e00cdda..0000000 --- a/commands/moderation/stop.js +++ /dev/null @@ -1,30 +0,0 @@ -const fs = require("fs"); -const got = require("got"); -const { Rcon } = require("rcon-client"); - -const { spawn } = require("child_process"); -let minecraftin; -module.exports = { - name: "stop", - description: "stop mc server", - guildOnly: true, - permissions: "KICK_MEMBERS", - async execute(message, args) { - const rcon = new Rcon({ - host: "mc.expand.gay", - port: 25575, - password: "6pnyf2DsCfHV67d3", - }); - await rcon.connect(); - let res = await rcon.send(`/stop`); - message.reply(`Server stopped Safely`); - }, -}; - -function spawnMC(channel) { - let options = { - detached: true, - shell: true, - cwd: "/home/harrison/Desktop/minecraft/", - }; -}