Skip to content

Instantly share code, notes, and snippets.

@vegeta897
Last active September 6, 2023 17:55
Show Gist options
  • Star 42 You must be signed in to star a gist
  • Fork 14 You must be signed in to fork a gist
  • Save vegeta897/e4410669c921c2ab7635e1d0153b0bc6 to your computer and use it in GitHub Desktop.
Save vegeta897/e4410669c921c2ab7635e1d0153b0bc6 to your computer and use it in GitHub Desktop.
(Outdated) Simple Minecraft server status bot command with Discord.js -- add me on Discord! vegeta897#7777
/*
##############################################################################
# #
# Sorry, this script is outdated and I can't justify maintaining it anymore. #
# #
# If you want to view the last version, it's archived here: #
# https://gist.github.com/vegeta897/e3d2fcd4b661bd9d021c397e7505be05 #
# #
# If you want to see a newer one that is similar, look here: #
# https://github.com/Baggette/minecraft-server-ping-example #
# #
##############################################################################
*/
@Brottweiler
Copy link

You could probably consider changing API, to https://mc-api.net/ for example.

@vegeta897
Copy link
Author

You could probably consider changing API, to https://mc-api.net/ for example.

I decided that there was no point in relying on an external service when the host of this script is already capable of performing the query itself.

@Rayg65
Copy link

Rayg65 commented Jan 9, 2021

thank you its worked but can you make it for embed messages? if you can it will be very nice

@vegeta897
Copy link
Author

thank you its worked but can you make it for embed messages? if you can it will be very nice

Thanks for your comment. I don't plan to change this script to use embeds instead of plain text because embeds can be disabled in the client, and it's beyond the scope of this gist to demonstrate how they are used. There are many tutorials and examples of creating embeds with Discord.js available online. Here's one: https://discordjs.guide/popular-topics/embeds.html

@nbendall34
Copy link

vegeta897, this is a pretty long gist, why don't you open a repo so people can leave issues in there?

@vegeta897
Copy link
Author

vegeta897 commented Jan 11, 2021

vegeta897, this is a pretty long gist, why don't you open a repo so people can leave issues in there?

I appreciate the thought. Before I explain why, let me just say this:

If anybody wants to make a repo using my code, they are welcome to! I will gladly add a link to it in the gist.

As for why I do not want to make a repo:

I intended this gist to be a simple, one-file example of a single-purpose bot.

Maybe I'm just being silly, but if I open a repo, then I would feel like I would have to turn it into a "real" bot with more files, configuration, and all the other typical repo dressings expected. I'm not interested in doing that work, or for that matter, providing more support than I already am for people who add me on Discord.

When people find a gist, there is a certain implication that it's more for demonstrative purposes, whereas repos indicate something more complete or fully developed, or something that intends to be. I imagine I would be closing a lot of feature request issues with the reason "out of scope." As it is, this comment thread is low-maintenance and I'm happy to keep responding here and on Discord.

I have to admit the comments could use some cleaning up though.

@ImGreenWolf
Copy link

How do I add more servers in a message?

@ImGreenWolf
Copy link

And how do I make it update it self?

@vegeta897
Copy link
Author

I've refactored the script a bit to separate the status update from the message function, so it's easier for people to modify the script to use the status in different ways, like using it in the bot's activity text.

@l3nnartt
Copy link

Error: connect ECONNREFUSED 85.190.150.145:25565
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1138:16) {
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '85.190.150.145',
port: 25565
}

@vegeta897
Copy link
Author

Error: connect ECONNREFUSED 85.190.150.145:25565

If your server doesn't work here, then it won't work in my script. Ensure that your server is in fact online and accessible from the internet.

@olebohmbach
Copy link

My Bot says "@ole, Minecraft server is online - Nobody is playing"
But the Server is offline.
Has anyone a Idea?

@vegeta897
Copy link
Author

My Bot says "@ole, Minecraft server is online - Nobody is playing"
But the Server is offline.
Has anyone a Idea?

Try querying your server on this site and see what it says: https://mcsrvstat.us/
If that site says it's offline but my script says it's online, I'd like to find out why. If you're comfortable sharing your server address with me for debugging, add me on Discord: vegeta897#7777

@olebohmbach
Copy link

I add you now on DC (Ole#1518)

@Khaogamermain01
Copy link

Does this work on Minecraft PE if it works contact me to tell me on Discord : Khao_Main#1451

@UmerAR
Copy link

UmerAR commented Feb 21, 2021

For me it keeps saying Error getting minecraft server status... and then in the terminal it says undefined how do i fixed that

@vegeta897
Copy link
Author

For me it keeps saying Error getting minecraft server status... and then in the terminal it says undefined how do i fixed that

Try querying your server on this site and see if it works there: https://mcsrvstat.us/

@fco131
Copy link

fco131 commented Mar 26, 2021

if you even find it wow you are dedicated but i was running this and got.
errno: -3008,
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: '173.67.133.217 '
}

@vegeta897
Copy link
Author

if you even find it wow you are dedicated but i was running this and got.
errno: -3008,
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: '173.67.133.217 '
}

Hello, it seems the problem is that you inserted a space at the end of your IP address (between the 7 and the end-quote). Make sure it's '173.67.133.217'

@Efnix
Copy link

Efnix commented Jun 23, 2021

i need help so i put the tokan and invited it to the server and when i run with visual studio code the bot just dosnt turn on pls help asap

@vegeta897
Copy link
Author

Hello @PurusWorldYT, are you using the console in Visual Studio Code to run node bot.js or whatever you named the script file? If so, does it show any errors after running that?

@DJKieranl29
Copy link

How do I make the bots precense change to say the amount of ppl online?

@tester248
Copy link

How can i make it do this for multiple mc servers and also autoupdate like every 5 mins

@mchedlo123
Copy link

how to run

@Brottweiler
Copy link

how to run

node mc-status-bot.js

@mroowak
Copy link

mroowak commented Feb 18, 2022

can i use it somehow to see who is playing?

@vegeta897
Copy link
Author

@mroowak you can modify the script to use util.queryFull on line 48 and adjust the message to include the player list. See the docs for more info on that function: https://passthemayo.gitbook.io/minecraft-server-util/api/query#queryfull

@fco131
Copy link

fco131 commented Feb 19, 2022 via email

@Timongcraft
Copy link

Can you update your script to discord.js@13?

@vegeta897
Copy link
Author

Can you update your script to discord.js@13?

Hi @Timong-craft, I appreciate the interest but I think it's time for me to archive this script. I just can't justify maintaining it any longer. If I was a user of discord.js and didn't have to research what changed in version 13 and test everything out I'd be more inclined, but at this point I feel this is one thing I need to let go. Sorry, and I hope you find another solution without much trouble!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment