# AeThex Unified Bot

## Overview

The AeThex Unified Bot is a comprehensive Discord bot designed to integrate community features, enterprise-level security, and multi-purpose server management. It aims to unify various functionalities into a single, powerful instance for the AeThex ecosystem.

Key capabilities include:
- **Community Engagement**: User verification, profile linking, realm selection, leaderboards, community posts, leveling system, role panels, and giveaways.
- **Sentinel Security**: Anti-nuke protection with RAM-based heat tracking to safeguard servers.
- **Federation Sync**: Cross-server role synchronization across multiple realms.
- **Support & Moderation**: A ticket system for support, a full suite of moderation tools (warn, kick, ban, timeout), and auto-moderation for content filtering.
- **Cross-Platform Integration**: Seamless connection with AeThex.studio and AeThex.foundation platforms.

## User Preferences

I prefer iterative development and receiving explanations that focus on the "why" behind changes, not just the "what". Please provide clear, step-by-step instructions for any complex tasks. I also appreciate it when you anticipate potential issues and suggest solutions proactively.

## System Architecture

The bot is built on **Node.js 20** using the **discord.js v14** framework. It follows a modular design with commands and event listeners separated into distinct directories.

**Key Architectural Decisions:**
- **Modular Command and Event Handling**: Commands are organized by function, and events are handled by dedicated listeners, promoting maintainability and scalability.
- **Unified XP System**: A cross-platform leveling system tracks XP from Discord messages, reactions, voice chat, daily claims, and AeThex platform activity. XP is unified across all platforms and stored in a single user profile.
    - Leveling formula: `level = floor(sqrt(xp / base))`, with configurable base difficulty.
    - **Prestige System**: Users can reset XP at Level 50 for permanent bonuses and rewards, including XP multipliers and unique badges.
- **Sentinel Security Module**: Implements RAM-based heat tracking for anti-nuke protection, monitoring for mass bans, kicks, role deletions, and channel deletions.
- **Federation Sync**: Manages cross-server role synchronization to ensure consistent access and permissions across linked guilds.
- **Interactive UI**: Utilizes Discord's button interactions for features like role panels and modals for custom embed creation.
- **Web Dashboard**: A `dashboard.html` file in the `public/` directory is available for potential web-based interactions or monitoring.

**Feature Specifications:**
- **40 Commands**: Covering community, leveling, moderation, utility, admin, cross-platform, and security functions.
- **Rich Embeds**: Used extensively for welcome/goodbye messages, user profiles, server info, and announcements.
- **Configurable Auto-moderation**: Settings for link, spam, badword, invite, and mention filtering with adjustable actions.
- **Scheduled Messages**: Allows scheduling timed announcements with support for embeds.
- **Giveaway System**: Automated creation, management, and rerolling of giveaways.
- **Achievement System**: Custom server achievements with various triggers (level, prestige, XP, messages, reactions, voice time, daily streak, commands used), XP rewards, role rewards, and hidden achievements.

## External Dependencies

-   **Database**: Supabase (used for `server_config`, `warnings`, `mod_actions`, `level_roles`, `role_panels`, `giveaways`, `scheduled_messages`, `automod_config`, `user_profiles`, `achievements`, `user_achievements`, and `user_stats` tables).
-   **Discord API**: `discord.js v14` for interacting with the Discord platform.
-   **AeThex.studio**: Integration for viewing user profiles.
-   **AeThex.foundation**: Integration for viewing user contributions.