Create a Discord bot that displays and manages the live status of a Minecraft server. The bot should show an embed that can be triggered by typing /livestatus in any channel within the server. The embed should include the following details about the Minecraft server:
* Server Name * IP Address (including port) * Server Version * MOTD (Message of the Day) * Number of Players Online * Server Status (Online or Offline) * Last Ping/Update Time
The bot should have configurable options, including a setting to define how often (in seconds) the bot will check and update the live status. The setup should be simple, with the option to integrate using either a Discord webhook or a Discord bot token. The embed should be visually appealing and easy for users to copy and share, ensuring a user-friendly experience.
also add a button called "playerlist" this should work as a playerlist of the server whenever you click this button it shows the online players inside the server looking into the ip address
NOTE: it only updates ONE embed, NOT sending another embed to update again.
add and install necessary dependencies it needs
if it needs to install something just tell me
the attachment is the example look of the embed:
Iโll create a Discord bot that displays live Minecraft server status with a beautiful embed and player list button.
Plan:
Create main bot file with slash command and button handlers
Set up Minecraft server ping functionality with auto-updates
Create config file for server settings
Create .env for Discord token
Create package.json with all dependencies
Installation Instructions
Run these commands in your project directory:
npm install
This will install:
discord.js - Discord bot framework
dotenv - Environment variable management
minecraft-server-util - Minecraft server status pinging
Setup Steps
Get Discord Bot Token:
Create New Application
Go to โBotโ โ Add Bot
Copy the token and paste it in
.envfile
Configure Server Details:
Edit
config.jsonwith your Minecraft server infoChange
updateIntervalto your preferred update frequency (in seconds)Optionally add a custom embed image URL
Start the Bot:
Shellnpm startInvite Bot to Server:
OAuth2 โ URL Generator
Scopes:
bot,applications.commandsPermissions: Send Messages, Embed Links, Use Slash Commands
Use generated URL to invite
Use the Command:
Type
/livestatusin any channelEmbed will auto-update every X seconds
Click โPlayer Listโ button to see online players
The bot is ready! It will maintain ONE embed that updates automatically without creating new messages.
install npm
Iโll check the projectโs package.json to see what dependencies need to be installed.
To install the npm dependencies for this Discord bot, run the following command in your terminal:
npm install
This will install the three dependencies listed in package.json:
discord.js (^14.14.1) - Discord bot framework
dotenv (^16.3.1) - Environment variable management
minecraft-server-util (^5.5.3) - Minecraft server status checking
After installation completes, you can start the bot with:
npm start
Make sure you have:
Node.js installed on your system
A valid Discord bot token in your
.envfile
node:internal/modules/cjs/loader:1408 throw err; ^ Error: Cannot find module '/home/container/index.js' at Function._resolveFilename (node:internal/modules/cjs/loader:1405:15) at defaultResolveImpl (node:internal/modules/cjs/loader:1061:19) at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1066:22) at Function._load (node:internal/modules/cjs/loader:1215:37) at TracingChannel.traceSync (node:diagnostics_channel:322:14) at wrapModuleLoad (node:internal/modules/cjs/loader:235:24) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:151:5) at node:internal/main/run_main_module:33:47 { code: 'MODULE_NOT_FOUND', requireStack: [] } Node.js v23.11.1
I need to check the package.json to see the entry point configuration.
The issue is clear: your hosting environment is trying to run index.js, but your botโs entry point is bot.js.
Fix: Create an index.js file that simply requires the bot:
This allows the hosting environment to find index.js while keeping your main bot code in bot.js.
๐
pasted-code-1767031937324.txt
txt
37 lines
โถ
npm error code ETARGET
npm error notarget No matching version found for minecraft-server-util@^5.5.3.
npm error notarget In most cases you or one of your dependencies are requesting
npm error notarget a package version that doesn't exist.
npm notice
npm notice New minor version of npm available! 11.6.4 -> 11.7.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.7.0
npm notice To update run: npm install -g npm@11.7.0
npm notice
npm error A complete log of this run can be found in: /home/container/.npm/_logs/2025-12-29T18_11_29_791Z-debug-0.log
npm install
npm error code ETARGET
npm error notarget No matching version found for minecraft-server-util@^5.5.3.
npm error notarget In most cases you or one of your dependencies are requesting
npm error notarget a package version that doesn't exist.
npm error A complete log of this run can be found in: /home/container/.npm/_logs/2025-12-29T18_11_47_409Z-debug-0.log
node:internal/modules/cjs/loader:1408
throw err;
^
Error: Cannot find module 'discord.js'
Require stack:
- /home/container/bot.js
- /home/container/index.js
at Function._resolveFilename (node:internal/modules/cjs/loader:1405:15)
at defaultResolveImpl (node:internal/modules/cjs/loader:1061:19)
at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1066:22)
at Function._load (node:internal/modules/cjs/loader:1215:37)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
at Module.require (node:internal/modules/cjs/loader:1491:12)
at require (node:internal/modules/helpers:135:16)
at Object. (/home/container/bot.js:1:134)
at Module._compile (node:internal/modules/cjs/loader:1734:14) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/home/container/bot.js', '/home/container/index.js' ]
}
Node.js v23.11.1
I can see the issue - thereโs a version mismatch with minecraft-server-util. Let me check the current package.json and fix it.
The issue is that minecraft-server-util@^5.5.3 doesnโt exist. The latest stable version is 5.4.3. Iโll fix the package.json:
Fixed the minecraft-server-util version from ^5.5.3 to ^5.4.3 (the latest available version). Now run npm install again and it should work.
Error pinging server: Socket closed unexpectedly while waiting for data
Iโll investigate the server pinging error in your Discord bot.
Now let me check the config to see the server settings:
I found the issue! The error โSocket closed unexpectedly while waiting for dataโ is occurring because:
Problem: Youโre trying to ping Hypixelโs Bedrock Edition server (port 19132) using the Java Edition status protocol from minecraft-server-util.
Solutions:
If you want to ping Hypixel Java Edition - Change port to 25565
If you want Bedrock Edition support - Use a different query method
Hereโs the fix for Java Edition (most common):
Changed port from 19132 (Bedrock) to 25565 (Java Edition). The minecraft-server-util library uses the Java Edition server list ping protocol, which wonโt work with Bedrock servers on port 19132.
If you specifically need Bedrock Edition support, youโll need to use the queryFull method instead of status, but note that Hypixel Bedrock may not have query enabled.
.env not showing when I make my project public so put the bot token insertion inside of config
Good question! Hereโs the situation:
Why .env doesnโt show up when public:
.envfiles are typically in.gitignoreto prevent exposing secretsThis is intentional and good for security
Options for handling this:
โ DONโT put token directly in config.json
If you push this to GitHub/public repo, your token will be exposed
Discord will automatically invalidate exposed tokens
Bad actors can use your bot token
โ Recommended approaches:
Keep using .env (BEST)
Add a
.env.examplefile to your repo with:Plain TextDISCORD_TOKEN=your_token_hereIn README, tell users to copy
.env.exampleto.envand add their tokenGit never tracks the actual
.envfile
Use config.json with environment variable fallback
In
config.json, put:"token": "REPLACE_WITH_YOUR_TOKEN"In your code, check if token looks like placeholder, then fall back to
process.env.DISCORD_TOKENStill requires users to either edit config or use .env
Hosting platforms (Replit, Heroku, etc.)
Use their built-in secrets/environment variables feature
Code reads from
process.env.DISCORD_TOKENNo local file needed
Current best practice:
Keep your current .env setup, just add .env.example to your repo so users know what to create!
What platform are you making this public on? That might affect the best approach.
.env not showing when I make my project public so put the bot token insertion inside of config
Plan:
Add
tokenfield to config.jsonUpdate bot.js to use
config.tokeninstead ofprocess.env.DISCORD_TOKENRemove dotenv dependency usage from bot.js
Bot token is now configured in config.json. Replace "your_discord_bot_token_here" with your actual Discord bot token.
require('./bot.js');