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 displays the scanned servers from my database, which is actively expanded by a seperate scanning program. You can access this yourself at https://api.cornbread2100.com/scannedServers.
If you find any bugs, please report them in the official discord.
You can contact me via discord: cornbread2100
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 bot's token and client id from the Discord Developer Portal in config.json. In order to make subsequent searches considerably faster, search results are temporarily saved. If it has been a while, the results will be fetched again. In the config, refreshDelay controlls how many seconds to wait before fetching the database again. About 600 (10 minutes) is recommended.
You'll need Node.js version v18 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. You'll need to install the maxmind and discord.js v14 packages to run the bot. If you don't know how, just run this command: npm install maxmind discord.js
.
Sends the bot's list of commands
Sends some stats about the bot
Fetches a random online Minecraft server
Fetches info from a given Minecraft server
The ip address of the server
The port of the server. Defaults to 25565. ㅤ
/search [minonline] [maxonline] [playercap] [isfull] [version] [hasimage] [description] [strictdescription] [player]
Searches the database for a server with specific properties
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 favicon
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. Note: this is very often inaccurate, as servers will send custom responses instead of a real player list, and not all servers send a player list. The player list also has a limited size, so players in big serverss won't be found.
Whether or not the server has player list enabled. This is true by default, but some servers disable it, especially if they're popular (The player list is limited to 12 players, so servers that are typically more active than 12 players will turn it off).
The oldest time a sever can be last seen. This doesn't mean the server is offline, it could be that the ping was lost due to packet loss.
The ip subnet a server's ip has to be within
The country the server is hosted in
Searches the database for live Twitch streamers
The language of the stream