ccashbot/commands/moderation/mc.js
Expand-sys c5f0808867 fix2
2021-10-19 09:35:12 +11:00

40 lines
1.1 KiB
JavaScript

const fs = require("fs");
const got = require("got");
const { Rcon } = require("rcon-client");
const { spawn } = require("child_process");
const rconpass = process.env.RCONPASS;
const host = process.env.MCHOST;
module.exports = {
name: "mc",
description: "send a Minecraft command",
guildOnly: true,
permissions: `${process.env.MCACCESS}`,
async execute(message, args) {
if (!args) {
return message.reply("OI you need to specify the command you want");
} else {
console.log(host);
const rcon = new Rcon({
host: `${host}`,
port: 25575,
password: `${rconpass}`,
});
await rcon.connect();
let content = message.content.substring(message.content.indexOf(" ") + 1);
console.log(content);
let speech = content.split("say ");
if (args[0] == "say") {
speech = content.split("say ");
speech[0] = `say ${message.author.username}: ${speech[1]} `;
}
let res = await rcon.send(`${speech[0]}`);
message.reply(`Sent Command ${content}: ${res}`);
rcon.end();
}
},
};