AddonPackager
A Discord bot and API that automates packaging Minecraft Bedrock Edition add-ons from GitHub repositories, featuring manifest versioning, code obfuscation, and detailed server statistics.
Overview
This project provides a comprehensive solution for Minecraft Bedrock Edition add-on developers, streamlining the process of packaging their creations. It consists of two main components: a Discord bot and a robust API server.
Discord Bot Features:
- Easy Packaging: Users can trigger the packaging process directly from Discord using slash commands.
- GitHub Integration: Connects to your GitHub repositories to fetch add-on files.
- Customizable Output: Allows specifying a custom name for the
.mcaddon
output file. - Branch Selection: Supports packaging from specific branches of your repository.
- Manifest Versioning: Ability to set a desired version for
manifest.json
files within your add-on, ensuring version control and compatibility. - Error Handling: Provides user-friendly error messages and ensures ephemeral replies for command execution issues.
API Server Features:
- Secure API: Utilizes an API key middleware for internal route protection.
- GitHub OAuth Callback: Handles GitHub OAuth flow to securely link user accounts and obtain access tokens for repository access.
- Bot Statistics:
- Uptime Monitoring: Provides the current uptime of the Discord bot in a human-readable format (e.g., "1d 2h 3m 4s").
- Server Count: Displays the number of Discord servers the bot is currently active in.
- Dynamic Changelogs: Serves changelog content for both the website and the bot, read directly from markdown files.
Addon Packager Core Logic:
The AddonPackager
class is central to the add-on creation process:
- Repository Download & Extraction: Downloads a specified GitHub repository as a zipball and extracts its contents.
- Automatic Pack Detection: Identifies "BP" (Behavior Pack) and "RP" (Resource Pack) folders within the extracted repository.
- JavaScript Obfuscation: Automatically obfuscates JavaScript files within the add-on packs, providing a layer of code protection.
- Comment Removal: Strips out comments from various file types to reduce file size and potential exposure of internal notes.
.mcaddon
Creation: Zips the processed behavior and resource packs into a single.mcaddon
file, ready for distribution.- Robust Error Handling: Includes comprehensive error handling and temporary directory cleanup.
Data Persistence: The application uses a file-based data persistence system:
- User data, including GitHub authentication tokens and configurations, is stored in a
data
directory, with each user having their own JSON file. - OAuth states are managed in-memory for security during the authentication flow.
- Data is loaded into memory on startup for quick access.
Changelog
nothing
Tags
Node.jsExpress.jsDiscord.jsNODE.JSarchiverjavascript-obfuscatordotenv