From 468b10443f948d1bf7d20381e98f4cdff8e510d1 Mon Sep 17 00:00:00 2001 From: Expand-sys Date: Tue, 19 Oct 2021 09:26:04 +1100 Subject: [PATCH] whitelist command and made app as a whole more portable --- commands/ccash/checkbal.js | 4 ++-- commands/moderation/mc.js | 17 ++++++++--------- commands/moderation/whitelist.js | 30 ++++++++++++++++++++++++++++++ commands/utility/args-info.js | 12 ------------ index.js | 2 ++ 5 files changed, 42 insertions(+), 23 deletions(-) create mode 100644 commands/moderation/whitelist.js delete mode 100644 commands/utility/args-info.js diff --git a/commands/ccash/checkbal.js b/commands/ccash/checkbal.js index 2bf6d9c..4ebc6e7 100644 --- a/commands/ccash/checkbal.js +++ b/commands/ccash/checkbal.js @@ -6,9 +6,9 @@ module.exports = { async execute(message, args) { let bal = await checkbal(message.author, args[0]); if (bal == -1) { - message.reply("User not found fucko"); + message.reply("User not found"); } else { - message.reply(bal.toString() + " piss points"); + message.reply(bal.toString() + " CCash"); } }, }; diff --git a/commands/moderation/mc.js b/commands/moderation/mc.js index 6518fa8..a841ef9 100644 --- a/commands/moderation/mc.js +++ b/commands/moderation/mc.js @@ -6,29 +6,28 @@ const { spawn } = require("child_process"); module.exports = { name: "mc", - description: "send a mc command", + description: "send a Minecraft command", guildOnly: true, - permissions: "SEND_MESSAGES", + permissions: `${process.env.MCACCESS}`, async execute(message, args) { if (!args) { return message.reply("OI you need to specify the command you want"); } else { const rcon = new Rcon({ - host: "mc.expand.gay", + host: `${host}`, port: 25575, - password: "6pnyf2DsCfHV67d3", + password: `${rconpass}`, }); await rcon.connect(); let content = message.content.substring(message.content.indexOf(" ") + 1); console.log(content); - let fuck = content.split("say "); + let speech = content.split("say "); if (args[0] == "say") { - fuck = content.split("say "); - fuck[0] = `say ${message.author.username}: ${fuck[1]} `; + speech = content.split("say "); + speech[0] = `say ${message.author.username}: ${speech[1]} `; } - console.log(fuck); - let res = await rcon.send(`${fuck[0]}`); + let res = await rcon.send(`${speech[0]}`); message.reply(`Sent Command ${content}: ${res}`); rcon.end(); diff --git a/commands/moderation/whitelist.js b/commands/moderation/whitelist.js new file mode 100644 index 0000000..201859f --- /dev/null +++ b/commands/moderation/whitelist.js @@ -0,0 +1,30 @@ +const fs = require("fs"); +const got = require("got"); + +const { Rcon } = require("rcon-client"); +const { spawn } = require("child_process"); + +module.exports = { + name: "whitelist", + description: "Whitelist yourself", + guildOnly: true, + permissions: "SEND_MESSAGES", + async execute(message, args) { + if (!args) { + return message.reply("OI you need to specify the command you want"); + } else { + const rcon = new Rcon({ + host: `${host}`, + port: 25575, + password: `${rconpass}`, + }); + + await rcon.connect(); + let content = message.content.split("!whitelist ")[1]; + let res = await rcon.send(`whitelist add ${content}`); + + message.reply(`whitelisted `); + rcon.end(); + } + }, +}; diff --git a/commands/utility/args-info.js b/commands/utility/args-info.js deleted file mode 100644 index 289f544..0000000 --- a/commands/utility/args-info.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - name: 'args-info', - description: 'Information about the arguments provided.', - args: true, - execute(message, args) { - if (args[0] === 'foo') { - return message.channel.send('bar'); - } - - message.channel.send(`First argument: ${args[0]}`); - }, -}; diff --git a/index.js b/index.js index 016e1e7..6c662dc 100644 --- a/index.js +++ b/index.js @@ -10,6 +10,8 @@ const dotenv = require("dotenv"); dotenv.config(); const prefix = process.env.PREFIX; +const rconpass = process.env.RCONPASS; +const host = process.env.HOST; const client = new Client({ intents: [