reazy26

Build me a dc bot where you can verify yourself with a minicraft plugin ingame and then its name on dc in the server

Kodari AI
KodariOct 29 at 2:54 pm 1
DiscordMinecraftVerifier
A Discord bot and Minecraft plugin pair that enables server members to verify their Minecraft identity through an in-game command. Players run /verify in Minecraft to receive a unique 6-character code, then use !verify <code> in Discord to link their accounts. The bot stores verified Discord-to-Minecraft mappings, assigns a verified role, and displays the linked Minecraft name in Discord via nickname change. Includes admin commands to view, remove, and manage verifications, plus a configurable verification role and channel restrictions. The Minecraft plugin generates time-limited codes, validates player identity, and communicates with the bot through a shared database or HTTP API.
  1. Create a Discord bot with /verify <code>, a short-lived code API, verified-role assignment, and Minecraft-name nicknames.

  2. Add a companion Minecraft /verify plugin that requests codes from the bot’s hosted API.

Created a Discord verification bot and companion Minecraft plugin.

Players run /verify in Minecraft to get a code, then use Discord’s /verify code command. On success, the bot assigns the configured verified role and changes their server nickname to their Minecraft name. Codes expire after 10 minutes.

To connect them:

  • Set BOT_TOKEN, GUILD_ID, VERIFIED_ROLE_ID, and a strong API_KEY from .env.example.

  • Set the same API_KEY and your bot’s public Kodari URL in minecraft-plugin/src/main/resources/config.yml.

  • Give the bot permission to manage roles and nicknames, and place its role above the verified role in the server’s role list.

  • The bot stores account links in data/links.json.

reazy26

where is the .jar

Kodari AI
KodariOct 29 at 3:02 pm 1

The .jar hasn’t been compiled yet. Click Compile in the top bar (on phone: ⋮ → Compile Project), then click Compile in the window. When it succeeds, use Download on the build or the Download {name}.jar button in chat.

reazy26

und discord bot?

Kodari AI
KodariOct 29 at 3:04 pm 1

The Discord bot isn’t a .jar—it’s the Node.js bot source in this project. Deploy it as a Discord bot project on Kodari to keep it online and provide the API URL for the Minecraft plugin. Set the bot’s environment variables first; the Minecraft plugin is the part you compile and download as a .jar.

Kodari can make mistakes. Review important code before using.
Files
minecraft-plugin
src
package.json
Code
6 347
minecraft-plugin/src/main/java/com/kodari/verification/VerificationPlugin.java
package com.kodari.verification;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

public final class VerificationPlugin extends JavaPlugin {
    private static final Pattern CODE_PATTERN = Pattern.compile("\\\"code\\\"\\s*:\\s*\\\"(\\d{6})\\\"");

    @Override
    public void onEnable() {
        saveDefaultConfig();
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player player)) {
            sender.sendMessage("Only players can use this command.");
            return true;
        }

        player.sendMessage("Requesting a Discord verification code...");
        Bukkit.getScheduler().runTaskAsynchronously(this, () -> {
            String code = requestCode(player);
            Bukkit.getScheduler().runTask(this, () -> {
                if (!player.isOnline()) {
                    return;
                }
                if (code == null) {
                    player.sendMessage("Could not contact the verification service. Please try again later.");
                } else {
                    player.sendMessage("Your Discord verification code is: " + code);
                    player.sendMessage("In Discord, run /verify and enter this code within 10 minutes.");
                }
            });
        });
        return true;
    }

    private String requestCode(Player player) {
        String apiUrl = getConfig().getString("api-url", "").trim();
        String apiKey = getConfig().getString("api-key", "").trim();
        if (apiUrl.isEmpty() || apiKey.isEmpty()) {
            getLogger().warning("Set api-url and api-key in config.yml before using /verify.");
            return null;
        }

        HttpURLConnection connection = null;
        try {
            connection = (HttpURLConnection) URI.create(apiUrl).toURL().openConnection();
            connection.setRequestMethod("POST");
            connection.setConnectTimeout(5000);
            connection.setReadTimeout(5000);
            connection.setDoOutput(true);
            connection.setRequestProperty("Authorization", "Bearer " + apiKey);
            connection.setRequestProperty("Content-Type", "application/json; charset=utf-8");

            String body = "{\"uuid\":\"" + player.getUniqueId() + "\",\"username\":\"" + player.getName() + "\"}";
            try (OutputStream output = connection.getOutputStream()) {
                output.write(body.getBytes(StandardCharsets.UTF_8));
            }

            if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
                return null;
            }
            try (InputStream input = connection.getInputStream(); Scanner scanner = new Scanner(input, StandardCharsets.UTF_8)) {
                String response = scanner.useDelimiter("\\A").hasNext() ? scanner.next() : "";
                Matcher matcher = CODE_PATTERN.matcher(response);
                return matcher.find() ? matcher.group(1) : null;
            }
        } catch (Exception exception) {
            getLogger().warning("Verification API request failed: " + exception.getMessage());
            return null;
        } finally {
            if (connection != null) {
                connection.disconnect();
            }
        }
    }
}