eyedchalice2148

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:

1 image attached
Kodari AI
KodariDec 29 at 5:34 pm 4,995 (v2)

Iโ€™ll create a Discord bot that displays live Minecraft server status with a beautiful embed and player list button.

MinecraftStatusBot
A Discord bot that monitors and displays live Minecraft server status through interactive embeds. Features include real-time server status updates, player count tracking, MOTD display, and an interactive player list button. The bot uses slash commands and auto-updates a single embed to show current server information including IP, port, version, and last ping time. Fully configurable with customizable update intervals.

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:

Shell
npm install

This will install:

  • discord.js - Discord bot framework

  • dotenv - Environment variable management

  • minecraft-server-util - Minecraft server status pinging

Setup Steps

  1. Get Discord Bot Token:

  2. Configure Server Details:

    • Edit config.json with your Minecraft server info

    • Change updateInterval to your preferred update frequency (in seconds)

    • Optionally add a custom embed image URL

  3. Start the Bot:

    Shell
    npm start
    
  4. Invite Bot to Server:

    • OAuth2 โ†’ URL Generator

    • Scopes: bot, applications.commands

    • Permissions: Send Messages, Embed Links, Use Slash Commands

    • Use generated URL to invite

  5. Use the Command:

    • Type /livestatus in any channel

    • Embed 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.

eyedchalice2148

install npm

Kodari AI
KodariDec 29 at 5:37 pm 1,444 (v2)

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:

Shell
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:

Shell
npm start

Make sure you have:

  1. Node.js installed on your system

  2. A valid Discord bot token in your .env file

eyedchalice2148

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

Kodari AI
KodariDec 29 at 6:10 pm 1,706 (v2)

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.

eyedchalice2148
๐Ÿ“Ž 1 file 1,907 chars
๐Ÿ“„
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
Kodari AI
KodariDec 29 at 6:12 pm 2,260 (v2)

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.

eyedchalice2148

Error pinging server: Socket closed unexpectedly while waiting for data

Kodari AI
KodariDec 29 at 6:18 pm 3,290 (v2)

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:

  1. If you want to ping Hypixel Java Edition - Change port to 25565

  2. 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.

eyedchalice2148

.env not showing when I make my project public so put the bot token insertion inside of config

Kodari AI
KodariDec 29 at 6:28 pm 1,147 (v2)

Good question! Hereโ€™s the situation:

Why .env doesnโ€™t show up when public:

  • .env files are typically in .gitignore to prevent exposing secrets

  • This 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:

  1. Keep using .env (BEST)

    • Add a .env.example file to your repo with:

      Plain Text
      DISCORD_TOKEN=your_token_here
      
    • In README, tell users to copy .env.example to .env and add their token

    • Git never tracks the actual .env file

  2. 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_TOKEN

    • Still requires users to either edit config or use .env

  3. Hosting platforms (Replit, Heroku, etc.)

    • Use their built-in secrets/environment variables feature

    • Code reads from process.env.DISCORD_TOKEN

    • No 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.

eyedchalice2148

.env not showing when I make my project public so put the bot token insertion inside of config

Kodari AI
KodariDec 29 at 6:28 pm 1,304 (v2)

Plan:

  • Add token field to config.json

  • Update bot.js to use config.token instead of process.env.DISCORD_TOKEN

  • Remove 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.

Kodari can make mistakes. Review important code before using.
Files
bot.js
config.json
index.js
package.json
README.md
Code
5 342
index.js
require('./bot.js');