C

Build a Production-Ready Discord Bot: RebirthStatus

You are an experienced Senior Java Software Engineer and Discord Bot Developer.

Your task is to build a 100% complete, production-ready Discord bot named RebirthStatus.

CRITICAL REQUIREMENTS

This project must be complete.

Do NOT generate placeholder code.

Do NOT leave TODO comments.

Do NOT omit any required files.

Do NOT generate pseudocode.

Every class must compile successfully.

The project must build successfully on the first Gradle build.

The project must contain ZERO compile errors.

The project must contain ZERO runtime errors.

The project must contain ZERO dependency conflicts.

The project must contain ZERO warnings.

The code must follow Java best practices, SOLID principles, and Clean Architecture.

Use JavaDocs where appropriate.

Implement proper exception handling throughout the project.

---

Project Information

Project Name:

RebirthStatus

Developer:

ItzMeTechu

Language:

Java 21

Discord Library:

JDA 5 (latest stable)

Build System:

Gradle (Kotlin DSL)

Database:

None

Configuration:

YAML

Logging:

SLF4J + Logback

License:

Proprietary

---

Bot Purpose

The bot monitors multiple Minecraft backend servers behind a Velocity network.

Every configured server is checked automatically every 10 seconds.

When a server changes state, the bot sends exactly one Discord webhook notification.

Supported states:

  • 🟒 Online
  • πŸ”΄ Offline

Only send notifications when the status changes.

Do not spam duplicate notifications.

---

Monitoring

Implement Minecraft Server List Ping to determine whether each configured server is online or offline.

Do not rely on Velocity APIs.

The bot must work independently.

Monitoring must be asynchronous.

No blocking operations.

Cache previous states.

---

Discord Webhook

Use Java HttpClient.

Do not use external webhook libraries.

Webhook payload must support:

  • username
  • avatar_url
  • embeds

Retry failed webhook requests up to three times.

Five-second timeout.

---

Embed Format

Online:

Title: 🟒 Server Online

Description:

The monitored server is now online.

Fields:

Server Name

Status

Time

Footer:

RebirthStatus β€’ Developed by ItzMeTechu

Thumbnail URL

Large Image URL

Timestamp

Green color (#57F287)

---

Offline:

Title: πŸ”΄ Server Offline

Description:

The monitored server has gone offline.

Fields:

Server Name

Status

Time

Footer:

RebirthStatus β€’ Developed by ItzMeTechu

Thumbnail URL

Large Image URL

Timestamp

Red color (#ED4245)

---

Configuration

Automatically generate config.yml on first startup.

Include:

Discord Token

Webhook URL

Bot Username

Avatar URL

Monitoring Interval

List of servers

Embed Colors

Images

Thumbnails

Footer

Validate configuration before startup.

Display useful errors for missing values.

---

Slash Commands

/status

/reload

/test-online

/test-offline

/help

Commands must register automatically.

---

Startup Banner

Display a professional purple ANSI ASCII banner.

Include:

Project Name

Version

Developer

Java Version

JDA Version

Startup Time

Status:

READY

---

Logging

Log:

Bot startup

Configuration loading

Webhook delivery

Monitoring events

Errors

Shutdown

---

Performance

Use ScheduledExecutorService.

Use thread-safe collections.

No memory leaks.

No unnecessary object creation.

Graceful shutdown.

---

Project Structure

Organize into packages:

config

commands

console

discord

embed

monitor

scheduler

service

util

listener

model

---

Gradle

Use Gradle Kotlin DSL.

Use the Shadow Plugin.

Produce one executable fat JAR.

Target Java 21.

---

Required Output

Generate the COMPLETE project.

Include:

settings.gradle.kts

build.gradle.kts

gradle.properties

README.md

LICENSE

.gitignore

Complete source code

resources

config generation

logging configuration

No file may be missing.

---

Final Verification

Before finishing, verify that:

  • The project builds successfully using "./gradlew build".
  • The project runs successfully with Java 21.
  • All imports resolve correctly.
  • No deprecated APIs are used.
  • No compile errors exist.
  • No runtime errors exist.
  • No missing dependencies exist.
  • Every class is fully implemented.
  • Every feature described above works correctly.

Do not shorten the implementation. Generate the entire production-ready project with complete source code and professional code quality.

Kodari AI
KodariAug 3 at 4:00 am 11
RebirthStatus
RebirthStatus independently monitors configured Minecraft backend servers through the Server List Ping protocol and posts Discord webhook embeds only when availability changes. It provides slash commands for viewing status, safely reloading configuration, sending test alerts, and viewing help. The Java 21 application uses JDA, YAML configuration, asynchronous networking, scheduled checks, retry-aware webhook delivery, structured logging, and graceful shutdown handling.

Created the complete RebirthStatus Java 21 Discord monitoring bot project with Gradle Kotlin DSL, JDA 5, YAML configuration generation and validation, asynchronous Minecraft status pings, webhook retry delivery, slash commands, logging, startup banner, fat-JAR configuration, documentation, and proprietary licensing.

C

Give me full setup tutorial I'm biggener at setup bot . Hosting in wispbyte

Kodari AI
KodariAug 3 at 7:20 am 4

RebirthStatus Setup Guide for Wispbyte

This guide assumes you have the RebirthStatus project folder and want to run it on a Wispbyte Java hosting server.


1. What you need

Before starting, make sure you have:

  • A Discord account with permission to create applications/webhooks in your Discord server.

  • A Wispbyte hosting account and Java server.

  • Java 21 selected on Wispbyte.

  • The RebirthStatus project files.

  • The IP address and port of each Minecraft backend server you want to monitor.

RebirthStatus checks the Minecraft backend servers directly using the Minecraft Server List Ping protocol.
Do not configure your Velocity proxy address unless that is specifically the server you want to monitor.


Part 1 β€” Create the Discord Bot

2. Create an application

  1. Click New Application.

  2. Enter the name: RebirthStatus

  3. Click Create.


3. Create the bot user

  1. In the left sidebar, open Bot.

  2. Click Add Bot and confirm.

  3. Optionally configure:

    • Username: RebirthStatus

    • Icon: Upload your bot logo, if desired.

  4. Under Token, click Reset Token or Copy.

  5. Save this token somewhere private temporarily.

Never share your Discord bot token. Anyone with it can control your bot.


4. Invite the bot to your Discord server

  1. In the Discord Developer Portal, open OAuth2 β†’ URL Generator.

  2. Under Scopes, select:

    • bot

    • applications.commands

  3. Under Bot Permissions, select:

    • Send Messages

    • Embed Links

    • Use Application Commands

    • View Channels

  4. Copy the generated URL at the bottom.

  5. Open the URL in your browser.

  6. Select your Discord server and click Authorize.

The bot must be in the Discord server for slash commands such as /status and /reload to appear.


Part 2 β€” Create the Discord Webhook

5. Create a webhook channel

RebirthStatus uses a Discord webhook for server online/offline notifications.

  1. Open your Discord server.

  2. Open the channel where you want alerts, such as #server-status.

  3. Click the channel settings gear icon.

  4. Select Integrations.

  5. Click Webhooks.

  6. Click New Webhook.

  7. Give it a name, such as RebirthStatus.

  8. Click Copy Webhook URL.

  9. Keep this URL private.

A webhook URL looks similar to this:

Plain Text
https://discord.com/api/webhooks/123456789012345678/long-webhook-token

Part 3 β€” Configure RebirthStatus

6. Build the bot locally

If you downloaded the complete source project, build the fat JAR before uploading it to Wispbyte.

Windows

Open Command Prompt or PowerShell inside the RebirthStatus folder:

Powershell
.\gradlew.bat shadowJar

Linux / macOS

Open a terminal inside the RebirthStatus folder:

Shell
chmod +x gradlew
./gradlew shadowJar

After it finishes, open:

Plain Text
build/libs/

You should find a JAR similar to:

Plain Text
RebirthStatus-1.0.0-all.jar

The file ending with -all.jar is the executable fat JAR. Upload that one to Wispbyte.

If your project uses build instead, run:

Shell
./gradlew build

Then look in build/libs/ for the JAR containing all dependencies.


7. Upload the bot to Wispbyte

  1. Log into the Wispbyte panel.

  2. Create a new Java server, if you have not already.

  3. Select Java 21 as the server Java version.

  4. Open the server Files or File Manager page.

  5. Upload the generated fat JAR:

    Plain Text
    RebirthStatus-1.0.0-all.jar
    
  6. Rename it to something simple, for example:

    Plain Text
    RebirthStatus.jar
    

8. Start once to generate config.yml

The bot automatically creates config.yml on first startup.

Set the Wispbyte startup command to:

Shell
java -Xms128M -Xmx512M -jar RebirthStatus.jar

Then start the server once.

The application should create:

Plain Text
config.yml

Stop the server after the file appears.

If the application stops with configuration validation errors on the first run, that is expected. It means it generated the configuration file but needs your Discord token, webhook URL, and server information.


9. Edit config.yml

Open config.yml in the Wispbyte file manager.

Enter your Discord bot token, webhook URL, and Minecraft backend servers.

A typical configuration looks like this:

YAML
discord:
  token: "PASTE_YOUR_DISCORD_BOT_TOKEN_HERE"

webhook:
  url: "PASTE_YOUR_DISCORD_WEBHOOK_URL_HERE"
  username: "RebirthStatus"
  avatar-url: ""

monitoring:
  interval-seconds: 10
  connect-timeout-seconds: 5

embeds:
  online-color: "#57F287"
  offline-color: "#ED4245"
  thumbnail-url: ""
  image-url: ""
  footer: "RebirthStatus β€’ Developed by ItzMeTechu"

servers:
  - name: "Survival"
    host: "127.0.0.1"
    port: 25565

  - name: "Skyblock"
    host: "127.0.0.1"
    port: 25566

  - name: "Prison"
    host: "203.0.113.10"
    port: 25565

Replace all example values with your real values.


10. Configuration explanation

Discord token

YAML
discord:
  token: "YOUR_TOKEN"

Paste the token from the Discord Developer Portal.

Do not include extra spaces or line breaks.


Webhook URL

YAML
webhook:
  url: "YOUR_WEBHOOK_URL"

Paste the full webhook URL copied from Discord.


Webhook bot name

YAML
webhook:
  username: "RebirthStatus"

This is the username shown on webhook alerts. You can change it:

YAML
webhook:
  username: "Network Status"

Avatar URL

YAML
webhook:
  avatar-url: ""

This is optional. To use a custom avatar, provide a direct image URL:

YAML
webhook:
  avatar-url: "https://example.com/rebirthstatus.png"

Leave it empty if you do not want one.


Monitoring interval

YAML
monitoring:
  interval-seconds: 10

This controls how frequently RebirthStatus checks all configured servers.

Recommended value:

YAML
interval-seconds: 10

Do not set this extremely low. Checking every 10 seconds is fast enough while avoiding unnecessary load.


Minecraft servers

Each monitored backend server needs:

  • A display name

  • An IP address or hostname

  • A Minecraft port

Example:

YAML
servers:
  - name: "Survival"
    host: "play.example.net"
    port: 25565

For servers hosted on the same Wispbyte node or machine, 127.0.0.1 may work only if both services share the same network namespace. Usually, use the address assigned by your hosting provider.

For another external server:

YAML
servers:
  - name: "Lobby"
    host: "192.168.1.50"
    port: 25565

For a server using a non-default port:

YAML
servers:
  - name: "Skyblock"
    host: "play.example.net"
    port: 25566

Embed images

These are optional direct image URLs:

YAML
embeds:
  thumbnail-url: "https://example.com/icon.png"
  image-url: "https://example.com/banner.png"

Requirements:

  • Use a direct HTTPS image URL.

  • Discord must be able to access the URL publicly.

  • PNG, JPG, JPEG, GIF, and WebP are generally suitable.

To disable an image, leave it empty:

YAML
thumbnail-url: ""
image-url: ""

Part 4 β€” Start the Bot

11. Configure the Wispbyte startup command

Use:

Shell
java -Xms128M -Xmx512M -jar RebirthStatus.jar

For a small monitoring bot, 512 MB maximum memory is normally more than enough.

If Wispbyte provides Java flags separately, set:

Plain Text
Minimum Memory: 128 MB
Maximum Memory: 512 MB
Java Version: 21

12. Start it

  1. Save config.yml.

  2. Return to the Wispbyte console.

  3. Start the server.

A successful startup should show:

  • Configuration loading messages

  • JDA connecting to Discord

  • Slash command registration

  • The purple RebirthStatus startup banner

  • READY status

  • Monitoring startup messages


Part 5 β€” Use the Discord Commands

Once the bot is online, use these slash commands in the Discord server where you invited it.

/status

Shows the currently known status of configured servers.

Use this to confirm that RebirthStatus is checking your backend servers.


/reload

Reloads the config.yml file without restarting the bot.

Use it after changing:

  • Server addresses

  • Server ports

  • Embed colors

  • Images

  • Webhook username

  • Monitoring settings

Example workflow:

  1. Edit and save config.yml in Wispbyte.

  2. Run:

    Plain Text
    /reload
    

/test-online

Sends a test online webhook notification.

Use this to confirm:

  • Your webhook URL is valid.

  • The webhook channel is correct.

  • The green embed format works.


/test-offline

Sends a test offline webhook notification.

Use this to confirm the red offline embed works correctly.


/help

Displays a list of commands and their descriptions.


Part 6 β€” How Notifications Work

RebirthStatus checks every configured Minecraft server every 10 seconds.

It sends a Discord webhook notification only when a status changes.

Example:

Previous state
New state
Notification
Unknown
Online
Online alert may be sent during the first successful check
Online
Online
No notification
Online
Offline
One offline alert
Offline
Offline
No notification
Offline
Online
One online alert

This prevents duplicate alert spam.


Part 7 β€” Important Velocity Network Notes

If you use Velocity, your setup may look like this:

Plain Text
Players
   ↓
Velocity Proxy
   ↓
Lobby Backend
Survival Backend
Skyblock Backend

Configure the actual backend servers, not necessarily the Velocity proxy:

YAML
servers:
  - name: "Lobby"
    host: "your-lobby-ip"
    port: 25565

  - name: "Survival"
    host: "your-survival-ip"
    port: 25566

  - name: "Skyblock"
    host: "your-skyblock-ip"
    port: 25567

RebirthStatus does not need Velocity plugins, Velocity API access, or access to your Minecraft server files.

It only needs network access to the server addresses and ports.


Part 8 β€” Troubleshooting

Bot does not come online

Check the Wispbyte console for errors.

Common causes:

Invalid Discord token

Symptoms:

Plain Text
LoginFailureException
Invalid token

Fix:

  1. Go to Discord Developer Portal.

  2. Open Bot.

  3. Reset and copy the token.

  4. Update config.yml.

  5. Restart the bot.


Slash commands do not appear

Check the following:

  • The bot was invited with both scopes:

    • bot

    • applications.commands

  • You are looking in the same Discord server where the bot was invited.

  • The bot is online.

  • Wait a few minutes after first registration; global Discord commands can take time to appear.

If necessary, remove the bot and reinvite it using the proper OAuth2 URL.


Webhook test fails

Run:

Plain Text
/test-online

Then inspect the Wispbyte console.

Common causes:

  • The webhook URL is incomplete.

  • The webhook URL was deleted in Discord.

  • Extra quotation marks were added incorrectly.

  • The hosting server cannot reach Discord due to network restrictions.

A valid webhook URL starts with:

Plain Text
https://discord.com/api/webhooks/

All Minecraft servers show offline

Check:

  1. The configured host is correct.

  2. The configured port is correct.

  3. The Minecraft server is actually running.

  4. The Minecraft server allows external connections.

  5. A firewall is not blocking its port.

  6. You are monitoring the backend serverβ€”not an unreachable private address.

For example, this will only work if RebirthStatus can reach that private address:

YAML
host: "192.168.1.50"

If your bot and Minecraft server are hosted separately, use the public IP or a hostname reachable from Wispbyte.


Connection timed out errors

This usually means Wispbyte cannot reach the Minecraft server.

Check the server firewall and make sure the Minecraft port is open:

Plain Text
25565

Or your custom backend port:

Plain Text
25566
25567

YAML configuration error

YAML is sensitive to spacing.

Correct:

YAML
servers:
  - name: "Survival"
    host: "play.example.net"
    port: 25565

Incorrect:

YAML
servers:
-name: "Survival"
host: "play.example.net"
port: 25565

Use spaces, not tabs.


Part 9 β€” Updating the Bot

When you receive a newer RebirthStatus JAR:

  1. Stop the Wispbyte server.

  2. Download a backup of your current config.yml.

  3. Delete or replace the old JAR.

  4. Upload the new JAR.

  5. Ensure the startup command still uses the correct JAR name:

    Shell
    java -Xms128M -Xmx512M -jar RebirthStatus.jar
    
  6. Start the server.

  7. Check the console for a successful READY status.

Do not delete config.yml unless you intentionally want to recreate your configuration.


Recommended Wispbyte Server Settings

Setting
Recommended value
Server type
Java
Java version
Java 21
Minimum memory
128 MB
Maximum memory
512 MB
Startup command
java -Xms128M -Xmx512M -jar RebirthStatus.jar
Auto restart
Enabled
Console access
Enabled

For a normal number of Minecraft backend servers, RebirthStatus should use very little CPU and memory.


Security Checklist

Before leaving the bot running:

  • Keep config.yml private.

  • Never send your Discord token in Discord messages.

  • Never share your webhook URL publicly.

  • Do not upload config.yml to GitHub.

  • Ensure .gitignore excludes config.yml.

  • Regenerate your Discord token immediately if it is exposed.

  • Delete and recreate a webhook if its URL is exposed.

Kodari can make mistakes. Review important code before using.
Files
gradle
src
.gitignore
build.gradle.kts
gradle.properties
gradlew
LICENSE
README.md
settings.gradle.kts
Code
31 1,736
src/main/java/com/itzmetechu/rebirthstatus/monitor/MinecraftStatusPing.java
package com.itzmetechu.rebirthstatus.monitor;

import com.itzmetechu.rebirthstatus.config.ApplicationConfig.ServerConfig;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.AsynchronousSocketChannel;
import java.nio.channels.CompletionHandler;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;

/**
 * Performs an asynchronous Minecraft Server List Ping without relying on Velocity.
 */
public final class MinecraftStatusPing {
    private static final Duration TIMEOUT = Duration.ofSeconds(5);

    /**
     * Checks whether a Minecraft server answers a valid status request.
     *
     * @param server server endpoint
     * @return future completing with {@code true} for a valid status response
     */
    public CompletableFuture<Boolean> ping(ServerConfig server) {
        CompletableFuture<Boolean> result = new CompletableFuture<>();
        AsynchronousSocketChannel channel;
        try {
            channel = AsynchronousSocketChannel.open();
        } catch (IOException exception) {
            return CompletableFuture.failedFuture(exception);
        }

        result.whenComplete((ignored, throwable) -> close(channel));
        channel.connect(new InetSocketAddress(server.host(), server.port()), null, new CompletionHandler<>() {
            @Override
            public void completed(Void ignored, Object attachment) {
                writeFully(channel, packet(handshake(server)), 0)
                    .thenCompose(unused -> writeFully(channel, ByteBuffer.wrap(new byte[]{1, 0}), 0))
                    .thenCompose(unused -> readVarInt(channel))
                    .thenCompose(length -> readFully(channel, length))
                    .thenApply(this::validStatusResponse)
                    .whenComplete((online, throwable) -> {
                        if (throwable == null) {
                            result.complete(online);
                        } else {
                            result.completeExceptionally(throwable);
                        }
                    });
            }

            @Override
            public void failed(Throwable throwable, Object attachment) {
                result.completeExceptionally(throwable);
            }

            private boolean validStatusResponse(byte[] response) {
                ByteBuffer buffer = ByteBuffer.wrap(response);
                int packetId = readVarInt(buffer);
                if (packetId != 0) {
                    return false;
                }
                int jsonLength = readVarInt(buffer);
                if (jsonLength < 2 || jsonLength > buffer.remaining()) {
                    return false;
                }
                byte[] json = new byte[jsonLength];
                buffer.get(json);
                String status = new String(json, StandardCharsets.UTF_8);
                return status.startsWith("{") && status.endsWith("}");
            }
        });
        return result.orTimeout(TIMEOUT.toMillis(), TimeUnit.MILLISECONDS);
    }

    private byte[] handshake(ServerConfig server) {
        byte[] host = server.host().getBytes(StandardCharsets.UTF_8);
        ByteBuffer data = ByteBuffer.allocate(1 + 5 + 5 + host.length + 2 + 1);
        writeVarInt(data, 0);
        writeVarInt(data, -1);
        writeVarInt(data, host.length);
        data.put(host);
        data.putShort((short) server.port());
        writeVarInt(data, 1);
        data.flip();
        byte[] packet = new byte[data.remaining()];
        data.get(packet);
        return packet;
    }

    private ByteBuffer packet(byte[] data) {
        ByteBuffer buffer = ByteBuffer.allocate(5 + data.length);
        writeVarInt(buffer, data.length);
        buffer.put(data);
        buffer.flip();
        return buffer;
    }

    private CompletableFuture<Void> writeFully(AsynchronousSocketChannel channel, ByteBuffer buffer, int ignored) {
        CompletableFuture<Void> result = new CompletableFuture<>();
        writeNext(channel, buffer, result);
        return result;
    }

    private void writeNext(AsynchronousSocketChannel channel, ByteBuffer buffer, CompletableFuture<Void> result) {
        channel.write(buffer, null, new CompletionHandler<>() {
            @Override
            public void completed(Integer written, Object attachment) {
                if (written < 0) {
                    result.completeExceptionally(new IOException("Minecraft server closed the connection."));
                } else if (buffer.hasRemaining()) {
                    writeNext(channel, buffer, result);
                } else {
                    result.complete(null);
                }
            }

            @Override
            public void failed(Throwable throwable, Object attachment) {
                result.completeExceptionally(throwable);
            }
        });
    }

    private CompletableFuture<Integer> readVarInt(AsynchronousSocketChannel channel) {
        CompletableFuture<Integer> result = new CompletableFuture<>();
        readVarIntByte(channel, 0, 0, result);
        return result;
    }

    private void readVarIntByte(
        AsynchronousSocketChannel channel,
        int value,
        int position,
        CompletableFuture<Integer> result
    ) {
        if (position >= 5) {
            result.completeExceptionally(new IOException("Minecraft VarInt exceeds five bytes."));
            return;
        }
        ByteBuffer byteBuffer = ByteBuffer.allocate(1);
        channel.read(byteBuffer, null, new CompletionHandler<>() {
            @Override
            public void completed(Integer read, Object attachment) {
                if (read == null || read < 1) {
                    result.completeExceptionally(new IOException("Minecraft server closed the connection."));
                    return;
                }
                byteBuffer.flip();
                int current = Byte.toUnsignedInt(byteBuffer.get());
                int combined = value | (current & 0x7F) << (position * 7);
                if ((current & 0x80) == 0) {
                    result.complete(combined);
                } else {
                    readVarIntByte(channel, combined, position + 1, result);
                }
            }

            @Override
            public void failed(Throwable throwable, Object attachment) {
                result.completeExceptionally(throwable);
            }
        });
    }

    private CompletableFuture<byte[]> readFully(AsynchronousSocketChannel channel, int length) {
        if (length < 1 || length > 1_048_576) {
            return CompletableFuture.failedFuture(new IOException("Minecraft response has an invalid length."));
        }
        ByteBuffer buffer = ByteBuffer.allocate(length);
        CompletableFuture<byte[]> result = new CompletableFuture<>();
        readNext(channel, buffer, result);
        return result;
    }

    private void readNext(AsynchronousSocketChannel channel, ByteBuffer buffer, CompletableFuture<byte[]> result) {
        channel.read(buffer, null, new CompletionHandler<>() {
            @Override
            public void completed(Integer read, Object attachment) {
                if (read == null || read < 0) {
                    result.completeExceptionally(new IOException("Minecraft server closed the connection."));
                } else if (buffer.hasRemaining()) {
                    readNext(channel, buffer, result);
                } else {
                    result.complete(buffer.array());
                }
            }

            @Override
            public void failed(Throwable throwable, Object attachment) {
                result.completeExceptionally(throwable);
            }
        });
    }

    private int readVarInt(ByteBuffer buffer) {
        int value = 0;
        for (int position = 0; position < 5; position++) {
            if (!buffer.hasRemaining()) {