PassTheMayo / minecraft-server-util

A Node.js library for Minecraft servers that can retrieve status, query, RCON, and send Votifier votes.
https://passthemayo.gitbook.io/minecraft-server-util/
MIT License
141 stars 24 forks source link

bug?: Query and QueryFull methods hanging on reachable servers #36

Closed b1tcr4sh closed 3 years ago

b1tcr4sh commented 3 years ago

Describe the bug: query and queryFull not resolving an object, making node.js hang. I tried this using both the address of my server, and the address of Hypixel (which is referenced in the example) and both have the same result, never resolving a response. I'm not sure this is just an issue with how it's being implemented, although I have used both the documentation and examples to derive what I have, and it's not working.

Code:

// This is a snippet from my Discord bot's '?mcserver info' command. 

async info(message, Discord) {
        let embed = new Discord.MessageEmbed();
        let queryMessage = await message.reply(`Querying Minecraft server ${address}...`);

        mcserver.queryFull(address)
        .then(response => {
            queryMessage.delete();

            embed.setTitle('Minecraft Server Information')
            .setColor('#42cef5')
            .setDescription(response.description.descriptionText)
            .addFields([{
                name: 'Online Players:',
                value: `${response.onlinePlayers} / ${response.maxPlayers}`
            },
            {
                name: 'Version:',
                value: response.version
            },
            {
                name: 'Server Address:',
                value: `${response.host}:${response.port}`
            },
            {
                name: 'Round Trip Latency:',
                value: response.roundTripLatency
            }]);

            console.log(response)

            message.channel.send(embed);
        })
        .catch(error => console.error(error));
    },

Expected behavior: The method is supposed to return a response object from the server, which would then be used to format and send a message embed in the Discord server.

Additional context Add any other context about the problem here

b1tcr4sh commented 3 years ago

After looking in the Discord server, some people were saying that this feature was broken in version 3.5.1 (which is the default version on npm), so downgrading to version 3.4.4 fixes my issues.