const { SlashCommandBuilder } = require('discord.js'); const { Client, Intents, Message, ActivityType} = require('discord.js'); const server_ip = "IP"; //replace with real ip for the server const server_port = 25565; // replace with the real port also thanks dashcruft for testing the code module.exports = { data: new SlashCommandBuilder() .setName('mcstatus') .setDescription('Shows status of the minecraft server'), async execute(interaction) util.status(server_ip, server_port, options,) .then((result) => { client.user.setPresence({ activities: [{ name: `${server_ip}`, type: ActivityType.Watching }], status: 'Online' }); const string1 = JSON.stringify(result);// turn the object into a string const string = JSON.parse(string1);// make the string parsable const embed = new EmbedBuilder() .setColor("#00008B") .setTitle("Status Server") .setDescription(`Mai jos sunt informatii in legatura cu serverul de minecraft \n **IP Server:** ${server_ip} \n **Port Server:** ${server_port}`) .addFields( {name:"Versiune", value: `${string.version.name}`}, //{name:"Server Protocol Version", value:`${string.version.protocol}`}, {name:"Players Online", value:`${string.players.online}`}, {name:"Max Players", value:`${string.players.max}`}, {name:"Message of the day", value:`${string.motd.clean}`}, {name:"Latency", value:`${string.roundTripLatency}`}, ) .setTimestamp() message.channel.send({embeds: [embed]})// send the embed }) .catch((error) => { console.log(error);// if the server was unable to be pinged or something else happened client.user.setPresence({ activities: [{ name: `Server is offline`, type: ActivityType.Watching }], status: 'dnd' }); const embed = new EmbedBuilder() .setColor("#FF0000") .setTitle("Status necunoscut") .setDescription(`Serverul este offline, se restarteaza sau are probleme de conexiune `) .setTimestamp() message.channel.send({embeds: [embed]})// send the embed })} .catch((error) => { console.log(error);// if the server was unable to be pinged or something else happened client.user.setPresence({ activities: [{ name: `Server is offline`, type: ActivityType.Watching }], status: 'dnd' }); const embed = new EmbedBuilder() .setColor("#FF0000") .setTitle("Status necunoscut") .setDescription(`Serverul este offline, se restarteaza sau are probleme de conexiune `) .setTimestamp() message.channel.send({embeds: [embed]})// send the embed })