Welcome to the Minecraft Server Monitor Bot! This bot helps you monitor the status of a Minecraft server, and can even attempt to restart it if it goes offline. The bot posts notifications directly to a Discord channel of your choice.
- Setup Command
/setup
: Configure the bot to monitor a Minecraft server by providing the server IP and a Discord channel for notifications. Optional parameters for Pterodactyl Panel integration are also available. - Status Command
/mc_status
: Check the current status of your Minecraft server with a simple command. - Start Command
/mc_start
: Attempt to start the Minecraft server if it is offline, using the Pterodactyl Panel API.
-
/setup
: Initializes the monitoring of a Minecraft server.server_ip
(required): The IP of the Minecraft server.channel
(required): The channel where notifications will be sent.panel_link
(optional): Link to the Pterodactyl panel.server_id
(optional): Server ID on the panel.api_key
(optional): API key for the panel.
-
/mc_status
: Reports the current status of the Minecraft server. -
/mc_start
: Attempts to start the server if it is offline.
- Node.js (v16+)
- NPM or Yarn
- A Discord bot token
- Optional: Pterodactyl Panel setup for automated restarts
-
Clone the repository:
git clone https://github.com/hihumanzone/Minecraft-Server-Monitor-Bot.git cd Minecraft-Server-Monitor-Bot
-
Install the required dependencies:
npm install discord.js mcping-js undici fs
or
yarn install discord.js mcping-js undici fs
-
Create a
config.json
file (only, this will be managed by the bot automatically). -
Add your bot token to the script:
client.login('your-bot-token');
-
Start the bot:
node bot.js
-
Invite the bot to your Discord server.
-
Use the
/setup
command to configure the bot with your Minecraft server's IP and a channel for notifications. -
Use
/mc_status
to check the current status of the Minecraft server. -
Use
/mc_start
to attempt to start the server if it is offline.
The bot uses a config.json
file to store configurations for each Discord server. This file is managed automatically by the bot, but should you need to inspect or modify it manually, it stores configurations as an array of entries, where each entry includes:
ip
: Minecraft server IPport
: Minecraft server portchannel
: Discord channel ID for notificationspanelLink
: Link to the Pterodactyl panel (optional)serverId
: Server ID on the panel (optional)apiKey
: API key for the panel (optional)guildOwner
: Discord guild owner IDrestartTimeout
: Timeout ID for automatic restart attemptsofflineNotified
: Boolean flag for offline notifications
Feel free to fork this repository and submit pull requests. Contributions are welcome!
This project is licensed under the MIT License. See the LICENSE file for more details.
For issues or support, please open an issue on the GitHub repository.
Happy monitoring! ๐ฎ