mirror of
https://github.com/aydenjahola/discord-multipurpose-bot.git
synced 2025-02-22 01:34:39 +00:00
minecraft: add whitelist command
This commit is contained in:
parent
7d8e76f875
commit
647d57fe82
3 changed files with 56 additions and 1 deletions
|
@ -16,3 +16,8 @@ TRACKER_API_KEY=YOUR_TRACKER_API_KEY
|
|||
|
||||
# Database
|
||||
MONGODB_URI=YOUR_MONGODB_URI
|
||||
|
||||
# RCON
|
||||
RCON_HOST=your_rcon_host
|
||||
RCON_PORT=your_rcon_port
|
||||
RCON_PASSWORD=your_rcon_password
|
49
commands/minecraft/whitelist.js
Normal file
49
commands/minecraft/whitelist.js
Normal file
|
@ -0,0 +1,49 @@
|
|||
const { SlashCommandBuilder } = require("discord.js");
|
||||
const { Rcon } = require("rcon-client");
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("whitelist")
|
||||
.setDescription("Auto-whitelist a user on the Minecraft server")
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.setName("username")
|
||||
.setDescription("The Minecraft username to whitelist")
|
||||
.setRequired(true)
|
||||
),
|
||||
isModOnly: true,
|
||||
|
||||
async execute(interaction) {
|
||||
const username = interaction.options.getString("username");
|
||||
await interaction.deferReply();
|
||||
|
||||
try {
|
||||
// committee only for now, remove once opened to public
|
||||
if (
|
||||
!interaction.member.permissions.has(PermissionFlagsBits.ManageGuild)
|
||||
) {
|
||||
await interaction.reply({
|
||||
content: "You do not have permission to use this command!",
|
||||
ephemeral: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const rcon = new Rcon({
|
||||
host: process.env.RCON_HOST,
|
||||
port: Number(process.env.RCON_PORT),
|
||||
password: process.env.RCON_PASSWORD,
|
||||
});
|
||||
await rcon.connect();
|
||||
const response = await rcon.send(`whitelist add ${username}`);
|
||||
await rcon.end();
|
||||
|
||||
await interaction.editReply(`RCON Response: ${response}`);
|
||||
} catch (error) {
|
||||
console.error("RCON Error:", error);
|
||||
await interaction.editReply(
|
||||
"There was an error executing the whitelist command."
|
||||
);
|
||||
}
|
||||
},
|
||||
};
|
|
@ -21,6 +21,7 @@
|
|||
"nodemailer": "^6.9.14",
|
||||
"owoify-js": "^2.0.0",
|
||||
"puppeteer": "^23.4.1",
|
||||
"rcon-client": "^4.2.5",
|
||||
"uuid": "^11.0.0"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue