This is the full code for a Node.js Minecraft server scanner Discord bot I made. This bot itself doesn't do the scanning, it just pings servers in the existing database, which is actively expanded by a seperate scanning program. (The code for the server scanner can be found here: https://github.com/kgurchiek/New-Minecraft-Server-IP-Scanner)
If you find any bugs, please report them in the official discord.
You can contact me via discord: Cornbread 2100#0001
If you just want to use the bot, you don't have to host it, you can try it out in its official Discord server
Enter the client id for the bot from the Discord Developer Portal in config.json. Then, Create a file called .env and then add token="<token>"
to .env and replace <token> with the token to your bot, adjust maxPings, pingTimeout, and refreshSearchTime as necessary:
If you have fast internet, you can set this pretty high (around 5000). If you have slower internet, you'll want it lower (around 1000). The higher it is, the less time a /search will take, but it will also be less accurate, especially if you have slower internet.
A range of 2000–3000 (2–3 seconds) is advised. Setting this lower will speed up a /search, but you risk excluding some slower servers whose responses take a little longer. Please note that this is in milliseconds, to prevent any confusion.
In order to make subsequent searches considerably faster, search results are momentarily saved. If it has been a while, as determined by refreshSearchTime, the results will be re-scanned. The advised number is 300 (5 minutes). Remember that the longer this is, the more inaccurate the results are likely to be, but the shorter it is, the longer the gap between scans will be. Remember that this is in seconds.
You'll need Node.js version 16.9.0 or later to operate the bot. Run "node deploy-commands.js" in your terminal before launching the bot. The slash instructions will then be registered; otherwise, they won't show up in Discord. Run "node index.js" to start the bot once you're ready.
Sends the bot's list of commands
Sends some stats about the bot
Fetches a random Minecraft server
Fetches the current status of a server
The ip address of the server
The port of the server
Attempts to fetch a list of players on a server
The ip address of the server
The port of the server ㅤ
/search [minonline] [maxonline] [playercap] [isfull] [version] [hasimage] [description] [strictdescription] [player]
Searches the database for a server with specific properties
How many servers to scan in the search. Use /stats to find the total servers available for scan.
The maximum player capacity of the server
The minimum number of players online
The maximum number of players online (Not to be confused with the server's maximum player capacity (playerCap))
Whether or not the server is full
The version of the server
Whether or not the server has a custom thumbnail image
The description of the server
(Used with the description argument) If true, the server's description has to perfectly match the description argument. If false, the server's description only has to contain the description argument
Searches for the server a player is currently playing on