mirror of
https://github.com/Expand-sys/ccashbot
synced 2025-12-16 23:52:14 +11:00
44 lines
1,005 B
JavaScript
44 lines
1,005 B
JavaScript
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, message);
|
|
},
|
|
};
|
|
|
|
function spawnMC(channel, message) {
|
|
let options = {
|
|
shell: true,
|
|
cwd: "/CCash/CCash/build",
|
|
};
|
|
let arguments = message.content.split("!ccash ");
|
|
console.log(arguments);
|
|
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}`);
|
|
});
|
|
}
|