N

UW Rebirth - Complete Discord Bot Development Prompt

Project Information

Bot Name: UW Rebirth Developer: ItzMeTechu Platform: Discord Language: Java 21 Build Tool: Gradle JDA Version: Latest Stable (JDA 5) Database: SQLite by default, MySQL supported Architecture: Modular, production-ready, scalable, asynchronous, SOLID principles, fully documented.

---

Objective

Develop a premium-quality Discord bot named UW Rebirth for Minecraft communities. The bot must be modern, fast, secure, configurable, and built for large servers.

Everything must be configurable using YAML configuration files. No hardcoded IDs, tokens, roles, channels, or messages.

---

Information Command

Create a dedicated information section.

/info

Displays a professional embed containing:

UW Rebirth

Premium Minecraft Discord Management Bot

Developer:

ItzMeTechu

Version:

Configurable

Build:

Configurable

Website:

Configurable

Support Server:

Configurable

GitHub:

Configurable

License:

Configurable

Footer:

Developed with ❤️ by ItzMeTechu

Add buttons:

• Website • Support • Documentation • Invite Bot

Everything configurable.

---

Core Features

  • Slash commands
  • Context menu commands
  • Buttons
  • Select menus
  • Modals
  • Rich embeds
  • Pagination
  • Auto complete
  • Localization support

---

Minecraft Features

  • Minecraft account linking
  • Whitelist applications
  • Verification
  • Role synchronization
  • Player profile lookup
  • Server status
  • Online players
  • TPS monitor
  • MSPT monitor
  • RAM usage
  • CPU usage
  • Ping monitor
  • Server uptime

---

Moderation

  • Ban
  • Temp Ban
  • Kick
  • Mute
  • Timeout
  • Warn
  • Soft Ban
  • Unban
  • Lockdown
  • Slowmode
  • Purge
  • Nickname management
  • Role management
  • Message logs
  • Moderation history

---

Ticket System

  • Support tickets
  • Report tickets
  • Purchase tickets
  • Staff applications
  • Builder applications
  • Developer applications
  • Ticket transcripts
  • Claim system
  • Close/Reopen
  • Ticket logs

---

Reports

  • Player reports
  • Staff reports
  • Evidence attachments
  • Case management
  • Staff notes
  • Investigation logs

---

Community

  • Welcome messages
  • Leave messages
  • Auto roles
  • Reaction roles
  • Leveling
  • Reputation
  • Suggestions
  • Polls
  • Giveaways
  • Announcements

---

Economy

  • Coins
  • Daily rewards
  • Weekly rewards
  • Referrals
  • Coupons
  • Purchase verification
  • Rank purchases
  • Redeem codes

---

PvP

  • Kill feed integration
  • Tournament registration
  • Leaderboards
  • Clan leaderboard
  • Bounty notifications
  • Event announcements

---

Staff Utilities

  • Staff dashboard
  • Staff activity logs
  • Shift tracking
  • Staff notes
  • Staff leaderboard
  • Staff statistics

---

Logging

Separate configurable logs for:

  • Member Join
  • Member Leave
  • Verification
  • Moderation
  • Tickets
  • Reports
  • Purchases
  • Giveaways
  • Polls
  • Suggestions
  • Role Changes
  • Channel Changes
  • Voice Activity
  • Message Delete
  • Message Edit
  • Errors
  • Commands
  • Bot Status

---

Security

  • Anti-spam
  • Anti-scam links
  • Anti-raid
  • Anti-mass mention
  • Anti-nuke protection
  • Permission validation
  • Rate limiting
  • Secure command execution

---

Configuration

Create professional configuration files:

  • config.yml
  • bot.yml
  • messages.yml
  • embeds.yml
  • tickets.yml
  • moderation.yml
  • economy.yml
  • logging.yml
  • permissions.yml
  • security.yml

Every setting must be configurable.

---

Performance

  • Fully asynchronous
  • Optimized for large Discord servers
  • Automatic reconnect
  • Command cooldowns
  • Memory optimized
  • Error recovery
  • Detailed logging

---

Developer Credits

Every startup log, /info command, and console banner should display:

UW Rebirth

Developed by:

ItzMeTechu

Copyright © All Rights Reserved.

Create a professional ASCII startup banner with the bot name and developer credit.

The project must compile without errors, follow clean code practices, and be production-ready with complete documentation and comments.

Kodari AI
KodariJul 31 at 2:26 am 1
UwRebirthBot
UW Rebirth is a modular Java 21 Discord bot for Minecraft communities, built with JDA 5 and Gradle. It provides configurable information commands, interaction handling, event and audit logging, security protections against spam, scams, raids, and mass mentions, SQLite or MySQL persistence, cooldown management, localization-ready YAML configuration, and an extensible foundation for moderation, tickets, verification, economy, staff tools, Minecraft integrations, and community systems.
N

How to setup this bot with fill tutorial

Kodari AI
KodariJul 31 at 2:27 am 1

UW Rebirth Setup Tutorial

This guide explains how to install, configure, invite, and run UW Rebirth.

1. Requirements

Install the following:

  • Java 21

  • Git, optional but recommended

  • Gradle 8+, or use the included Gradle Wrapper

  • A Discord account

  • A Discord server where you have Administrator permission

  • A Discord application created in the Discord Developer Portal

Check Java:

Shell
java -version

You should see Java 21, for example:

Plain Text
openjdk version "21.x.x"

If Java is not installed, download it from:

Verify Gradle if using a system installation:

Shell
gradle --version

The project can also be run with:

Shell
./gradlew

On Windows:

Powershell
gradlew.bat

2. Create the Discord Application

  1. Open the Discord Developer Portal:

  2. Click New Application.

  3. Enter:

    Plain Text
    UW Rebirth
    
  4. Click Create.

  5. Open the General Information page.

  6. Set the application description if desired:

    Plain Text
    Premium Minecraft Discord Management Bot
    
  7. Upload a bot icon if you have one.


3. Create the Bot User

  1. Open the Bot page in the left sidebar.

  2. Click Reset Token or Copy Token.

  3. Store the token securely.

Do not:

  • Put the token inside Java source code.

  • Commit the token to GitHub.

  • Paste the token into screenshots or public Discord messages.

  • Add the token directly to YAML files.

If the token is exposed, immediately reset it in the Developer Portal.

The project expects the token in this environment variable by default:

Plain Text
DISCORD_TOKEN

This is configured in:

Plain Text
config/bot.yml

The default setting is:

YAML
bot:
  token-environment-variable: DISCORD_TOKEN

4. Enable Required Privileged Intents

UW Rebirth uses member, message, moderation, voice, and presence-related functionality.

Open:

Developer Portal → Your Application → Bot

Enable these intents:

  • Presence Intent

  • Server Members Intent

  • Message Content Intent

Depending on your JDA configuration and enabled modules, also ensure the bot has access to:

  • Guild messages

  • Guild moderation

  • Guild voice states

  • Guild presences

Click Save Changes.

Without the privileged intents, features such as message security, member logging, and presence monitoring may not function correctly.


5. Invite the Bot

Open:

Developer Portal → OAuth2 → URL Generator

Select the following scopes:

  • bot

  • applications.commands

For a development server, the easiest permission option is:

Plain Text
Administrator

However, for production, it is safer to use only the permissions required by the modules you enable.

At minimum, the bot may need permissions such as:

  • View Channels

  • Send Messages

  • Send Messages in Threads

  • Embed Links

  • Attach Files

  • Read Message History

  • Manage Messages

  • Moderate Members

  • Kick Members

  • Ban Members

  • Manage Nicknames

  • Manage Roles

  • Manage Channels

  • Manage Webhooks

  • View Audit Log

  • Connect

  • Speak

Generate the invite URL, open it in your browser, select your server, and authorize the bot.

The bot must be invited by someone who has permission to manage the server.


6. Download or Open the Project

If using Git:

Shell
git clone YOUR_REPOSITORY_URL
cd uw-rebirth

If you downloaded a ZIP file:

  1. Extract the project.

  2. Open a terminal inside the extracted project folder.

  3. Confirm that the folder contains:

Plain Text
build.gradle
settings.gradle
src/

The project uses:

Plain Text
Java 21
Gradle
JDA 5
SQLite by default
MySQL optionally

7. Configure the Bot Token

Linux and macOS

Run:

Shell
export DISCORD_TOKEN="YOUR_BOT_TOKEN"

Example:

Shell
export DISCORD_TOKEN="MTAxxxxxxxxxxxxxxxxxxxxxxxx"

This only applies to the current terminal session.

To persist the variable, add the export command to your shell configuration file, such as:

Shell
~/.bashrc

or:

Shell
~/.zshrc

Then reload it:

Shell
source ~/.bashrc

Windows PowerShell

For the current PowerShell session:

Powershell
$env:DISCORD_TOKEN="YOUR_BOT_TOKEN"

To persist it for your Windows user account:

Powershell
[Environment]::SetEnvironmentVariable(
    "DISCORD_TOKEN",
    "YOUR_BOT_TOKEN",
    "User"
)

Close and reopen PowerShell after setting the persistent variable.

Windows Command Prompt

For the current session:

Cmd
set DISCORD_TOKEN=YOUR_BOT_TOKEN

Check that the variable exists.

Linux/macOS:

Shell
echo $DISCORD_TOKEN

PowerShell:

Powershell
echo $env:DISCORD_TOKEN

Do not display the value in a public screenshot or support request.


8. First Startup

Run the bot from the project directory.

Linux and macOS

Shell
./gradlew clean build
java -jar build/libs/uw-rebirth-1.0.0.jar

If the Gradle wrapper is not executable:

Shell
chmod +x gradlew
./gradlew clean build

Windows

Powershell
gradlew.bat clean build
java -jar build\libs\uw-rebirth-1.0.0.jar

You can also start it directly through Gradle:

Shell
./gradlew run

Windows:

Powershell
gradlew.bat run

On the first startup, UW Rebirth creates:

Plain Text
config/

and copies the default configuration files into it:

Plain Text
config/
├── config.yml
├── bot.yml
├── messages.yml
├── embeds.yml
├── tickets.yml
├── moderation.yml
├── economy.yml
├── logging.yml
├── permissions.yml
└── security.yml

Stop the bot with:

Plain Text
Ctrl+C

Edit the generated files in config/, then start the bot again.

Do not normally edit the default files inside:

Plain Text
src/main/resources/

Those are bundled templates. The runtime files in config/ are the files intended for server-specific configuration.


9. Main Configuration

Open:

Plain Text
config/config.yml

Default configuration:

YAML
database:
  type: sqlite
  sqlite:
    file: uwrebirth.db
  mysql:
    jdbc-url: jdbc:mysql://localhost:3306/uwrebirth
    username: root
    password: change-me
    pool-size: 10

commands:
  cooldown-seconds: 3
  development-guild-id: ""

localization:
  default-locale: en

SQLite setup

SQLite is enabled by default:

YAML
database:
  type: sqlite
  sqlite:
    file: uwrebirth.db

The bot will create the database file automatically in the working directory:

Plain Text
uwrebirth.db

SQLite is recommended for:

  • Development

  • Small and medium servers

  • Single-instance bot hosting

  • Simple installations

MySQL setup

For MySQL, create a database first:

SQL
CREATE DATABASE uwrebirth
  CHARACTER SET utf8mb4
  COLLATE utf8mb4_unicode_ci;

Then configure:

YAML
database:
  type: mysql
  mysql:
    jdbc-url: jdbc:mysql://localhost:3306/uwrebirth
    username: uwrebirth
    password: YOUR_DATABASE_PASSWORD
    pool-size: 10

For a remote MySQL server, use the correct hostname:

YAML
jdbc-url: jdbc:mysql://mysql.example.com:3306/uwrebirth

Make sure the database server accepts connections from the machine hosting the bot.

Use MySQL when you need:

  • Multiple bot instances

  • A remote database server

  • Centralized backups

  • Larger deployments

  • External database administration


10. Bot Identity and Presence

Open:

Plain Text
config/bot.yml

Example:

YAML
bot:
  token-environment-variable: DISCORD_TOKEN
  version: 1.0.0
  build: Production
  activity: Minecraft Communities
  status: ONLINE

You can change the displayed information:

YAML
bot:
  token-environment-variable: DISCORD_TOKEN
  version: 1.0.0
  build: Production
  activity: UW Rebirth Minecraft Network
  status: ONLINE

The environment variable name can also be changed:

YAML
bot:
  token-environment-variable: UW_REBIRTH_TOKEN

If you change it, define the matching environment variable:

Shell
export UW_REBIRTH_TOKEN="YOUR_BOT_TOKEN"

11. Configure /info

Open:

Plain Text
config/embeds.yml

Example:

YAML
info:
  title: UW Rebirth
  description: Premium Minecraft Discord Management Bot
  developer: ItzMeTechu
  website: https://yourwebsite.com
  support-server: https://discord.gg/your-support-server
  github: https://github.com/your-account/your-repository
  license: All Rights Reserved
  footer: Developed with ❤️ by ItzMeTechu
  color: "#5865F2"
  ephemeral: false

buttons:
  website:
    label: Website
    url: https://yourwebsite.com
  support:
    label: Support
    url: https://discord.gg/your-support-server
  documentation:
    label: Documentation
    url: https://yourwebsite.com/docs
  invite-bot:
    label: Invite Bot
    url: https://discord.com/oauth2/authorize

Replace all placeholder URLs before using the command.

The current command is:

Plain Text
/info

The information command displays the bot name, description, developer, version, build, website, support server, GitHub, license, and configurable buttons.


12. Configure Commands

Open:

Plain Text
config/messages.yml

Example:

YAML
commands:
  info-description: Display information about UW Rebirth.
  ping-description: Check bot latency and status.
  ping-response: Pong! UW Rebirth is operational.
  profile-unavailable: Profile services are not configured yet.

Available basic commands currently include:

Plain Text
/info
/ping

The bot also registers a message context command:

Plain Text
View User Profile

After startup, wait a few seconds for Discord to update the commands.

If commands do not appear:

  1. Confirm the bot was invited with applications.commands.

  2. Confirm the bot is in the correct server.

  3. Restart the bot.

  4. Check the console for command registration errors.

  5. Make sure the bot token belongs to the intended application.


13. Configure Logging Channels

Open:

Plain Text
config/logging.yml

Each channel setting accepts a Discord channel ID.

Example:

YAML
enabled: true

embed:
  title: UW Rebirth Audit Log
  color: "#5865F2"

channels:
  member_join: "123456789012345678"
  member_leave: "123456789012345678"
  verification: "123456789012345678"
  moderation: "123456789012345678"
  tickets: "123456789012345678"
  reports: "123456789012345678"
  purchases: "123456789012345678"
  giveaways: "123456789012345678"
  polls: "123456789012345678"
  suggestions: "123456789012345678"
  role_changes: "123456789012345678"
  channel_changes: "123456789012345678"
  voice_activity: "123456789012345678"
  message_delete: "123456789012345678"
  message_edit: "123456789012345678"
  errors: "123456789012345678"
  commands: "123456789012345678"
  bot_status: "123456789012345678"

Enable Developer Mode

To copy channel IDs:

  1. Open Discord.

  2. Go to User Settings.

  3. Open Advanced.

  4. Enable Developer Mode.

  5. Right-click a channel.

  6. Select Copy Channel ID.

  7. Paste the ID into the YAML file.

Ensure the bot can view and send messages in every configured logging channel.

An empty value disables that individual logging destination:

YAML
member_join: ""

14. Configure Permissions and Roles

Open:

Plain Text
config/permissions.yml

Example:

YAML
administrator:
  bypass-security: true

roles:
  staff: "123456789012345678"
  moderator: "123456789012345678"
  support: "123456789012345678"
  verified: "123456789012345678"

commands:
  info: ""
  ping: ""

Copy role IDs in the same way:

  1. Enable Discord Developer Mode.

  2. Open Server Settings → Roles.

  3. Right-click a role.

  4. Select Copy Role ID.

  5. Paste it into the appropriate setting.

Example:

YAML
roles:
  staff: "111111111111111111"
  moderator: "222222222222222222"
  support: "333333333333333333"
  verified: "444444444444444444"

Do not put a role higher than the bot’s highest role if the bot needs to manage it.

To move the bot role:

  1. Open Server Settings.

  2. Select Roles.

  3. Drag the UW Rebirth role above roles it must manage.

  4. Keep the bot below server-owner or protected administrative roles.


15. Configure Security

Open:

Plain Text
config/security.yml

Example:

YAML
anti-spam:
  enabled: true
  message-limit: 6
  window-seconds: 8

anti-scam:
  enabled: true
  pattern: "(?i)(free-nitro|discordgift|steamcommunitу|claim-prize)"

anti-raid:
  enabled: true
  join-limit: 10
  window-seconds: 30

anti-mass-mention:
  enabled: true
  threshold: 5

anti-nuke:
  enabled: true
  maximum-dangerous-actions: 5
  window-seconds: 30

actions:
  delete-message: true
  timeout-minutes: 10
  notify-channel: true

rate-limits:
  commands-per-minute: 30
  buttons-per-minute: 60

Recommended starting values:

YAML
anti-spam:
  enabled: true
  message-limit: 6
  window-seconds: 8

anti-scam:
  enabled: true

anti-raid:
  enabled: true
  join-limit: 10
  window-seconds: 30

anti-mass-mention:
  enabled: true
  threshold: 5

Adjust these values based on your server activity. A busy community may need a higher spam threshold to avoid false positives.


16. Configure Tickets

Open:

Plain Text
config/tickets.yml

Example:

YAML
enabled: true
category-id: "123456789012345678"

transcripts:
  enabled: true
  channel-id: "123456789012345678"

claim:
  enabled: true
  required-role-id: "123456789012345678"

Create the following Discord channels:

  • Ticket category

  • Transcript log channel

Then copy their IDs into the configuration.

The ticket types are already defined:

YAML
types:
  support:
    enabled: true
    label: Support Ticket
  report:
    enabled: true
    label: Report Ticket
  purchase:
    enabled: true
    label: Purchase Ticket
  staff-application:
    enabled: true
    label: Staff Application
  builder-application:
    enabled: true
    label: Builder Application
  developer-application:
    enabled: true
    label: Developer Application

A ticket staff role can be configured using:

YAML
claim:
  required-role-id: "YOUR_SUPPORT_ROLE_ID"

17. Configure Moderation

Open:

Plain Text
config/moderation.yml

The moderation configuration file is copied into config/ on first startup. Configure the values there for your server.

Typical items to configure include:

  • Moderation log channel

  • Staff role

  • Moderator role

  • Default timeout duration

  • Warning behavior

  • Case numbering

  • Audit messages

The bot should have the appropriate Discord permissions before enabling moderation functionality.

For moderation actions to work correctly:

  • The bot role must be above the target user’s role.

  • The bot must have Moderate Members for timeouts.

  • The bot must have Kick Members for kicks.

  • The bot must have Ban Members for bans.

  • The bot must have Manage Messages for purge and message deletion.

  • The executor must have the configured permission or staff role.


18. Configure Economy

Open:

Plain Text
config/economy.yml

Configure:

  • Currency name

  • Currency symbol

  • Daily reward amount

  • Weekly reward amount

  • Referral rewards

  • Coupon behavior

  • Purchase verification

  • Rank purchase settings

  • Redeem-code settings

For example, currency settings may look like:

YAML
currency:
  name: Coins
  symbol: 🪙

Keep all economy configuration in the runtime config/economy.yml file.


19. Configure Messages and Localization

Open:

Plain Text
config/messages.yml

You can change command responses, error messages, logging messages, and security warnings.

Example:

YAML
errors:
  cooldown: Please wait before using this command again.
  unknown-command: This command is not available.
  generic: An unexpected error occurred. Please try again later.

security:
  mass-mention: A mass mention was blocked.
  scam-link: A suspicious link was blocked.
  spam: Spam was blocked.

The default locale is configured in:

YAML
localization:
  default-locale: en

inside:

Plain Text
config/config.yml

When changing YAML text, preserve quotation marks where needed. For example, messages containing : or special YAML characters should be quoted.


20. Build the Bot

From the project directory, run:

Shell
./gradlew clean build

Windows:

Powershell
gradlew.bat clean build

A successful build creates:

Plain Text
build/libs/uw-rebirth-1.0.0.jar

If the build fails, check:

  • Java is version 21.

  • The internet connection is available for dependency downloads.

  • You are running the command from the project root.

  • build.gradle and settings.gradle exist.

  • Your configuration files contain valid YAML.


21. Start the Bot

Run the compiled JAR:

Linux/macOS:

Shell
java -jar build/libs/uw-rebirth-1.0.0.jar

Windows:

Powershell
java -jar build\libs\uw-rebirth-1.0.0.jar

A successful startup displays the UW Rebirth banner and connects to Discord.

The console should show that:

  • Configuration loaded.

  • Database initialized.

  • Discord login succeeded.

  • Commands were registered.

  • Logging and security services started.


22. Run the Bot in the Background

Linux with screen

Install screen if necessary, then run:

Shell
screen -S uw-rebirth
export DISCORD_TOKEN="YOUR_BOT_TOKEN"
java -jar build/libs/uw-rebirth-1.0.0.jar

Detach with:

Plain Text
Ctrl+A, then D

Reattach later:

Shell
screen -r uw-rebirth

Linux with tmux

Shell
tmux new -s uw-rebirth
export DISCORD_TOKEN="YOUR_BOT_TOKEN"
java -jar build/libs/uw-rebirth-1.0.0.jar

Detach with:

Plain Text
Ctrl+B, then D

Reattach with:

Shell
tmux attach -t uw-rebirth

Linux systemd service

Create:

Plain Text
/etc/systemd/system/uw-rebirth.service

Example:

Ini
[Unit]
Description=UW Rebirth Discord Bot
After=network.target

[Service]
Type=simple
User=uwrebirth
WorkingDirectory=/opt/uw-rebirth
Environment=DISCORD_TOKEN=YOUR_BOT_TOKEN
ExecStart=/usr/bin/java -jar /opt/uw-rebirth/build/libs/uw-rebirth-1.0.0.jar
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target

Secure the service file because it contains the token:

Shell
sudo chmod 600 /etc/systemd/system/uw-rebirth.service

Start the service:

Shell
sudo systemctl daemon-reload
sudo systemctl enable uw-rebirth
sudo systemctl start uw-rebirth

Check its status:

Shell
sudo systemctl status uw-rebirth

View logs:

Shell
journalctl -u uw-rebirth -f

For stronger security, use an environment file rather than placing the token directly in the service file.


23. Recommended Production Permissions

For initial testing, you can invite the bot with Administrator permissions.

For production:

  1. Create a dedicated bot role.

  2. Place it above roles it must manage.

  3. Remove Administrator if it is not necessary.

  4. Grant only the permissions required by enabled modules.

  5. Restrict logging channels so only staff can view them.

  6. Keep transcript channels private.

  7. Keep moderation and error logs private.

  8. Do not grant the bot ownership or unnecessary server-management permissions.


24. Basic Testing Checklist

After starting the bot, test the following:

Plain Text
/info
/ping

Then verify:

  • The bot appears online.

  • /info displays the configured values.

  • Info buttons open the correct URLs.

  • Commands are visible in the intended server.

  • Join events appear in the configured log channel.

  • Leave events appear in the configured log channel.

  • Edited messages are logged.

  • Deleted messages are logged.

  • Spam protection responds correctly.

  • Suspicious links are handled correctly.

  • Mass mentions are blocked according to configuration.

  • The SQLite database is created.

  • Tickets use the configured category.

  • Ticket transcripts use the configured channel.

  • Staff roles are recognized.

  • The bot can perform configured moderation actions.


25. Common Problems

The bot does not start

Check that the token exists:

Linux/macOS:

Shell
echo $DISCORD_TOKEN
N

I am using a hosting service

Kodari AI
KodariJul 31 at 2:28 am 1

What would you like help with on your hosting service—deploying the Discord bot, configuring environment variables, installing dependencies, or keeping it online?

Tell me the hosting provider and share any error message you’re seeing.

Kodari can make mistakes. Review important code before using.
Files
src
.gitignore
build.gradle
README.md
settings.gradle
Code
26 1,136
src/main/java/com/itzmetechu/uwrebirth/database/DatabaseManager.java
package com.itzmetechu.uwrebirth.database;

import com.itzmetechu.uwrebirth.config.ConfigManager;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public final class DatabaseManager implements AutoCloseable {
    private static final Logger LOGGER = LoggerFactory.getLogger(DatabaseManager.class);

    private final ConfigManager config;
    private final ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor();
    private HikariDataSource dataSource;

    public DatabaseManager(ConfigManager config) {
        this.config = config;
    }

    public void initialize() {
        HikariConfig hikari = new HikariConfig();
        String type = config.getString("config.yml", "database.type", "sqlite");

        if ("mysql".equalsIgnoreCase(type)) {
            hikari.setJdbcUrl(config.getString("config.yml", "database.mysql.jdbc-url",
                "jdbc:mysql://localhost:3306/uwrebirth"));
            hikari.setUsername(config.getString("config.yml", "database.mysql.username", "root"));
            hikari.setPassword(config.getString("config.yml", "database.mysql.password", ""));
            hikari.setMaximumPoolSize(config.getInt("config.yml", "database.mysql.pool-size", 10));
        } else {
            hikari.setJdbcUrl("jdbc:sqlite:" +
                config.getString("config.yml", "database.sqlite.file", "uwrebirth.db"));
            hikari.setMaximumPoolSize(1);
        }

        hikari.setPoolName("UW-Rebirth-Database");
        hikari.setConnectionTimeout(10000);
        hikari.setInitializationFailTimeout(10000);
        dataSource = new HikariDataSource(hikari);
        createSchema();
        LOGGER.info("Database initialized using {}.", type.toUpperCase());
    }

    private void createSchema() {
        String[] statements = {
            """
            CREATE TABLE IF NOT EXISTS users (
                discord_id VARCHAR(32) PRIMARY KEY,
                minecraft_uuid VARCHAR(36),
                minecraft_name VARCHAR(16),
                locale VARCHAR(16) NOT NULL DEFAULT 'en',
                coins BIGINT NOT NULL DEFAULT 0,
                created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
                updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
            )
            """,
            """
            CREATE TABLE IF NOT EXISTS moderation_cases (
                id INTEGER PRIMARY KEY,
                guild_id VARCHAR(32) NOT NULL,
                user_id VARCHAR(32) NOT NULL,
                moderator_id VARCHAR(32) NOT NULL,
                action VARCHAR(32) NOT NULL,
                reason TEXT,
                expires_at TIMESTAMP,
                created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
            )
            """,
            """
            CREATE TABLE IF NOT EXISTS tickets (
                id INTEGER PRIMARY KEY,
                guild_id VARCHAR(32) NOT NULL,
                channel_id VARCHAR(32) NOT NULL,
                creator_id VARCHAR(32) NOT NULL,
                type VARCHAR(32) NOT NULL,
                status VARCHAR(16) NOT NULL DEFAULT 'OPEN',
                claimed_by VARCHAR(32),
                created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
                closed_at TIMESTAMP
            )
            """,
            """
            CREATE TABLE IF NOT EXISTS audit_log (
                id INTEGER PRIMARY KEY,
                guild_id VARCHAR(32),
                actor_id VARCHAR(32),
                event_type VARCHAR(64) NOT NULL,
                details TEXT,
                created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
            )
            """
        };

        try (Connection connection = dataSource.getConnection();
             Statement statement = connection.createStatement()) {
            for (String sql : statements) {
                statement.executeUpdate(sql);
            }
        } catch (SQLException exception) {
            throw new IllegalStateException("Could not create database schema.", exception);
        }
    }

    public CompletableFuture<Void> recordAudit(String guildId, String actorId, String eventType, String details) {
        return CompletableFuture.runAsync(() -> {
            String sql = "INSERT INTO audit_log (guild_id, actor_id, event_type, details) VALUES (?, ?, ?, ?)";
            try (Connection connection = dataSource.getConnection();
                 var statement = connection.prepareStatement(sql)) {
                statement.setString(1, guildId);
                statement.setString(2, actorId);
                statement.setString(3, eventType);
                statement.setString(4, details);
                statement.executeUpdate();
            } catch (SQLException exception) {
                LOGGER.error("Could not write audit event {}.", eventType, exception);
            }
        }, executor);
    }

    @Override
    public void close() {
        executor.close();
        if (dataSource != null) {
            dataSource.close();
        }
    }
}