From 1d743e8d02884e182be9796c1c8d55c00b2fdac3 Mon Sep 17 00:00:00 2001 From: Expand Date: Mon, 18 Dec 2023 00:03:52 +1100 Subject: [PATCH] aaa --- commands/slashcommands/utility/query.js | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 commands/slashcommands/utility/query.js diff --git a/commands/slashcommands/utility/query.js b/commands/slashcommands/utility/query.js new file mode 100644 index 0000000..67c4b1d --- /dev/null +++ b/commands/slashcommands/utility/query.js @@ -0,0 +1,32 @@ +const { CommandInteraction, ApplicationCommandType, ApplicationCommandOptionType, EmbedBuilder } = require('discord.js'); +const { sendResponse, sendReply, channelSend } = require('../../../utils/utils'); +const path = require('path'); +const { Rcon } = require("rcon-client"); +const dig = require("gamedig") + + +module.exports = { + name: `query`, + description: `Fetch a the query response from server`, + cooldown: 5, + type: ApplicationCommandType.ChatInput, + /** + * @param {CommandInteraction} interaction + */ + async execute(interaction) { + const { member, guild, options } = interaction + await interaction.deferReply({ ephemeral: false }).catch(err => console.error(`There was a problem deferring an interaction: `, err)); + dig.query({ + type: 'minecraft', + host: process.env.MCHOST, + port: process.env.MCHOSTPORT, + }).then((state) => { + //console.log(state); + //console.log(state.players) + interaction.sendResponse(state) + }).catch(async (error) => { + console.log("Server is offline " + error); + interaction.sendResponse("Server is offline") + }); + }, +} \ No newline at end of file