Skip to content

feat: modernize monorepo, upgrade Lavalink v4 & cipher, enhance dashboard, and fix auth/tooling - #829

Open
PhantomNimbi wants to merge 54 commits into
galnir:mainfrom
PhantomNimbi:main
Open

feat: modernize monorepo, upgrade Lavalink v4 & cipher, enhance dashboard, and fix auth/tooling#829
PhantomNimbi wants to merge 54 commits into
galnir:mainfrom
PhantomNimbi:main

Conversation

@PhantomNimbi

Copy link
Copy Markdown

Summary of Changes

This pull request provides a comprehensive modernization of the Master-Bot monorepo, upgrading core framework dependencies, implementing a robust Lavalink v4 audio engine architecture with YouTube OAuth and remote cipher support, modernizing the web dashboard and tRPC backend, and streamlining developer launcher tooling.


1. 🎵 Audio Engine & Music Architecture (Lavalink v4)

  • Lavalink v4 Migration & Remote Cipher Support:
    • Updated plugin coordinates to youtube-plugin:1.18.2 and lavasrc-plugin:4.8.3 in application.yml.
    • Configured remote cipher integration (https://cipher.kikkia.dev/) with configurable environment variables (YOUTUBE_CIPHER_URL, YOUTUBE_CIPHER_PASSWORD) for unthrottled InnerTube extraction.
    • Injected runtime YouTube refresh token and API credentials directly into JVM system properties (-DYOUTUBE_REFRESH_TOKEN, -DYOUTUBE_SKIP_INIT=true, -DYOUTUBE_CIPHER_URL, -DSPOTIFY_CLIENT_ID).
  • YouTube OAuth Device Flow:
    • Added owner-restricted /youtube-auth slash command and backend handler (youtubeOAuth.ts) leveraging YouTube's InnerTube TV client credentials (https://www.youtube.com/o/oauth2/device/code).
    • Enforced zero .env disk mutation at runtime by persisting tokens atomically to gitignored .youtube-oauth.json.
  • Queue & Playback Engine:
    • Updated Queue.start() to supply explicit encodedTrack and encoded payloads for full lavalink-client v2 and Lavalink v4 compatibility.
    • Fixed Redis list operations and voice connection state tracking in Queue.ts.
    • Enhanced /skip and /skipto interaction responses with suppressed link embeds and accurate position validation.

2. 🌐 Web Dashboard & tRPC Modernization

  • Next.js & React Upgrade:
    • Migrated dashboard to modern Next.js App Router with @tanstack/react-query v5 and tRPC v11.
    • Resolved Server/Client boundary serialization issues in root layouts and client providers.
  • Commands Panel & Category Organization:
    • Added categorized tabs (Music, GIFs, Other) and search filtering in /dashboard/[server_id]/commands.
    • Filtered out globally disabled administrative commands (such as owner authentication utilities) from standard guild toggle lists.
  • Dual-Domain Authentication Support:
    • Made NEXTAUTH_URL optional in @master-bot/auth with fallback to NEXTAUTH_URL_INTERNAL / http://localhost:3000.
    • Enabled trustHost: true for NextAuth v5 to seamlessly support simultaneous access across both localhost and public reverse proxies.
    • Updated internal bot tRPC client to prioritize NEXTAUTH_URL_INTERNAL for zero-latency local RPC.

3. 🛠️ Monorepo Tooling & Developer Experience

  • Unified Launcher Scripts (scripts/dev.mjs & scripts/start.mjs):
    • Added cross-platform port freeing (freePort()) before startup to prevent zombie socket lockouts on ports 3000, 2333, 5432, and 6379.
    • Added automated prerequisites checks for Java >=17, PostgreSQL, and Redis.
    • Built clear ANSI status dashboard banners highlighting active ports, running services, cipher endpoints, and log locations.
    • Added automated pre-launch build verification in start.mjs ensuring .next production bundles exist prior to spawning production servers.
    • Improved .env parser in common.mjs to preserve tab-aligned inline notes without corrupting quotes.

4. 🧹 Code Hygiene & Type Safety

  • Type-checked and verified all monorepo packages:
    • @master-bot/bot
    • @master-bot/dashboard
    • @master-bot/api
    • @master-bot/auth
    • @master-bot/db
  • Removed duplicate dead router definitions and fixed Discord ID mapping in logs procedures.

…nce bot & dashboard

- Upgrade Next.js to 15.2.0 and migrate App Router to async request APIs (await params, useParams)

- Upgrade Auth.js/NextAuth to v5 beta with server action handlers and safe Discord avatar URL resolution

- Upgrade @next/eslint-plugin-next to 15.2.0 and align environment parsers to @t3-oss/env-* 0.13.11

- Replace pure-ESM env wrapper in @master-bot/bot with native Zod schema parsing for 100% CJS compatibility

- Wire dynamic feature flags (LAVA_ENABLED, GIFS_ENABLED, TWITCH_ENABLED, NEWS_ENABLED, IGDB_ENABLED) across bot preconditions

- Connect automated cross-platform PostgreSQL and Redis service checks (connect-or-auto-launch)

- Implement dynamic command help registry and standardized help tables across all 60 slash commands

- Enhance web dashboard with active-tab sidebar navigation, server overview statistics, and Redis log streaming

- Resolve next-themes hydration mismatch by adding suppressHydrationWarning to root layout
…sabled commands

- Group slash commands into structured categories (GIFs & Anime, Twitch, News, Games & Entertainment, General & Utilities)

- Filter out categories and individual commands disabled globally via environment feature flags (LAVA_ENABLED, GIFS_ENABLED, TWITCH_ENABLED, NEWS_ENABLED, IGDB_ENABLED)

- Display server-specific enable/disable toggles and active status badges for all active commands
…ys monorepo-wide

- Configure remoteCipher in application.yml with default endpoint (https://cipher.kikkia.dev/) and support custom YOUTUBE_CIPHER_URL / YOUTUBE_CIPHER_PASSWORD

- Pass deterministic Java system properties (-D) for YouTube OAuth, skipInitialization, cipher, and Spotify credentials in launcher scripts

- Wire YOUTUBE_CIPHER_URL and YOUTUBE_CIPHER_PASSWORD into @master-bot/bot, @master-bot/api, @master-bot/dashboard env schemas and .env.example

- Display active cipher endpoint in dev and production console status banners
@PhantomNimbi

Copy link
Copy Markdown
Author

🚀 PR Update: Interactive Info Commands (About & Dashboard)

Adds a refined /about command with professional, human-readable info and a new /dashboard command linking to the web dashboard.


📦 Key Enhancements

  • /about command:
    • Upgraded to deliver detailed, human-readable info with an optional type option (choices: Bot / Server / User) that defaults to Bot info when omitted (Discord's API does not permit a true default alongside registered subcommands).
    • Bot: servers, total users, uptime, tag, ID, current activity, and useful links (invite, commands, support server).
    • Server: owner, members, online count, channel breakdown, roles, boost level, creation date, ID, and locale.
    • User (/about type: User + optional user: @target): display name, ID, bot flag, account created, joined date, top role, and role list.
    • All repository references point to upstream galnir/Master-Bot (never the fork).
  • New /dashboard command:
    • Standalone command returning a link to the web dashboard via NEXTAUTH_URL/NEXTAUTH_URL_INTERNAL, with a graceful message when the dashboard is unconfigured.
    • Documents the new command and updates the command count from 66 to 67 in the README and wiki Commands Reference.

🧪 Verification & Status

  • Type Safety & Build: Bot compiles with 0 errors via pnpm --filter @master-bot/bot build.

🔗 Pushed Commits

  • 85da8e2feat(bot): upgrade about command and add dashboard command
  • 5dd984fdocs: add dashboard command and update command count to 67

@PhantomNimbi

Copy link
Copy Markdown
Author

🎉 PR Complete: Ready for Review

This PR is now complete and fully verified — all planned features, upgrades, and bug fixes described in this branch have been implemented, built, type-checked, and runtime-tested.


✅ Final Verification Status

  • Type Safety & Build: All packages verified with 0 errors (auth, api, bot, dashboard).
  • Bot Application: 67 slash commands registered with the Discord API.
  • Web Dashboard: Next.js 15 App Router production build verified.
  • Audio Engine: Lavalink v4 + remote cipher + full InnerTube client roster (MUSIC, ANDROID_VR, IOS, TV, WEB, WEBEMBEDDED) with reliable playback.
  • Runtime: Music trivia, moderation suite, ticket system, and unified /set settings verified in production.

🚀 What's In This PR

feat: modernize monorepo, upgrade Lavalink v4 & cipher, enhance dashboard, and fix auth/tooling
  • Music: Lavalink v4 migration, remote cipher, YouTube InnerTube roster, music trivia, voice routing fixes, owner /youtube-auth.
  • Moderation & Tickets: 5 moderation commands (/ban, /kick, /slowmode, /timeout, /purge) and a thread-based support ticket system.
  • Settings: Unified /set command (17 subcommands) and web dashboard management panels.
  • Dashboard: Next.js 15, tRPC v11, React Query 5, NextAuth v5 Discord OAuth.
  • Tooling: Control-panel launcher scripts, automatic DB sync, CommonJS build resolution, CI/CD alignment, wiki documentation.

🙏 Request for Review

@galnir — this branch is ready for your review and merge. Please let me know if any changes are needed. The full maintenance roadmap with stage-by-stage history is tracked in upstream issue #828.

@PhantomNimbi

Copy link
Copy Markdown
Author

🚀 PR Update: Dashboard Command Link Formatting Fix

The /dashboard slash command has been improved to render the dashboard link with clean alt text instead of exposing the raw URL, and to correctly handle access from the same system as the bot host.


📦 Key Enhancements

  • [/dashboard Command]:
    • Replaced the raw plain-text URL field with a clickable markdown hyperlink using alt text — [Click here to open the dashboard](<url>). The exact URL is no longer displayed verbatim in Discord.
    • Keeps the external NEXTAUTH_URL preference with the internal NEXTAUTH_URL_INTERNAL fallback, so the link resolves correctly whether accessed locally on the bot host or externally.

🧪 Verification & Status

  • Type Safety & Build: @master-bot/bot verified with 0 errors (pnpm --filter @master-bot/bot build).

🔗 Pushed Commits

  • d1533c8fix(bot): format dashboard link with alt text in /dashboard command

… music controls

- Add /reminder with background scheduler (ReminderManager), tRPC router, and dashboard management pages
- Add /world-news command powered by NewsAPI with country and category filtering
- Add interactive button-based /connect-four and /tic-tac-toe mini-games
- Add dynamic 6-stage rotating StatusManager presence system
- Replace /skip with Now Playing Next button and rename /skipto to /jump
- Add repeat and shuffle action buttons to Now Playing embed and fix track duration display
- Refactor /about to standard Discord subcommands (bot, server, user)
- Implement cross-platform recursive killProcessTree in launcher scripts to eliminate zombie processes
- Standardize CommandHelp help objects and deferred interaction handling across all commands
@PhantomNimbi

Copy link
Copy Markdown
Author

🚀 PR Update: Reminders, News, Button Games & Enhanced Music Controls

Pushed a major update introducing the /reminder subsystem with web dashboard integration, NewsAPI integration, interactive button games, clean rotating presence statuses, modernized music controls, and cross-platform launcher process tree cleanup.


📦 Key Enhancements

  • ⏰ Reminders Engine & Dashboard Integration:
    • Implemented /reminder add, /reminder list, and /reminder remove slash commands.
    • Added background scheduler ReminderManager polling every 30s for due reminders and dispatching styled Discord channel alerts.
    • Added full web management control panel (/dashboard/reminders and /dashboard/[server_id]/reminders) via tRPC reminder router.
  • 📰 World News Integration:
    • Implemented /world-news slash command fetching headlines from NewsAPI with country and category filtering.
  • 🎮 Interactive Button Games:
    • Implemented /connect-four and /tic-tac-toe standalone slash commands with Discord button grids and real-time interaction listeners.
  • ✨ Dynamic Status Rotation:
    • Built StatusManager rotating across 6 clean presence formats every 25 seconds.
  • 🎵 Modernized Music Queue Controls & Duration Accuracy:
    • Replaced /skip with the interactive Next button on the Now Playing embed, and renamed /skipto to /jump.
    • Added repeat and shuffle queue action buttons to the Now Playing embed.
    • Fixed duration parsing in Song.ts to read track.info.duration resolving the 00:00 display issue.
    • Forced noReplace: false in Lavalink track updates to guarantee instant audio switching on skip/jump.
  • ℹ️ /about Subcommands:
    • Refactored /about to standard Discord subcommands: bot, server, and user [user: @User].
  • 🛠️ Cross-Platform Process Management:
    • Added recursive killProcessTree in scripts/common.mjs, dev.mjs, and start.mjs ensuring zero orphaned Node child processes on stop/restart.
  • 📖 Documentation & Registry:
    • Updated README.md and wiki/Commands-Reference.md reflecting 69 slash commands.

🧪 Verification & Status

  • Type Safety & Build: All packages verified with 0 errors (@master-bot/auth, @master-bot/api, @master-bot/bot, @master-bot/dashboard).
  • Runtime Verification: Tested and confirmed operational in Discord.

🔗 Pushed Commits

  • 40108f4feat(bot): add reminders, news, games, status rotation, and modernize music controls

…erence

- Add ticketRoleId to Guild model in Prisma schema and synchronize database
- Add setRole procedure to tRPC tickets router
- Add /set ticket-role and /set ticket-role-disable subcommands
- Automatically add ticket manager role members to new support ticket threads and alert the role
- Fix deferReply/editReply interaction conflict in /reminder command
- Audit and align all 70 slash commands in README.md and wiki/Commands-Reference.md
@PhantomNimbi

Copy link
Copy Markdown
Author

🚀 PR Update: Support Ticket Manager Role & Command Reference Audit

Pushed an update implementing the support ticket manager role configuration, automated role member assignment to ticket threads, and auditing all 70 slash commands in the reference documentation.


📦 Key Enhancements

  • 🎫 Support Ticket Manager Role:
    • Added ticketRoleId to Prisma schema and updated PostgreSQL database.
    • Added /set ticket-role role: @Role and /set ticket-role-disable subcommands.
    • Automatically fetches and adds all members holding the ticket manager role to newly created private support threads, and mentions <@&ticketRoleId> for instant staff notification.
  • 🔍 Command Reference Audit & Bug Fixes:
    • Audited and updated README.md and wiki/Commands-Reference.md to accurately reflect all 70 slash commands and their exact parameter signatures.
    • Resolved deferReply / editReply conflict in /reminder.

🧪 Verification & Status

  • Type Safety & Build: All packages verified with 0 errors (@master-bot/auth, @master-bot/api, @master-bot/bot, @master-bot/dashboard).
  • Runtime Verification: Tested and confirmed operational.

🔗 Pushed Commits

  • 33dbf0efeat(tickets): add ticket manager role support and audit commands reference

- Restore /pat command with Klipy & Waifu.im API reaction gifs
- Restore /now-playing command to display current track and interactive music controls on demand
- Restore /weather command with wttr.in real-time meteorological reports and 3-day forecast
- Restore /bored command with Bored API v2 and internal curated activity engine
- Restore /poll command with interactive Discord button voting and live progress bars
- Update README.md and wiki/Commands-Reference.md to document all 75 slash commands
@PhantomNimbi

Copy link
Copy Markdown
Author

🚀 PR Update: Legacy Command Restoration & Monorepo Modernization

Pushed an update restoring all target legacy commands from prior versions of Master-Bot, modernized for Discord.js v14 and Sapphire Framework.


📦 Key Enhancements

  • /pat (gifs): Anime head-patting reaction GIF powered by Klipy API and Waifu.im (/pat [target: @User]).
  • /now-playing (music): Standalone command to repost the active music player embed on demand with real-time duration and button controls.
  • /weather (other / info): Real-time meteorological reports, humidity, wind, UV index, and 3-day forecast via wttr.in (/weather location: <City>).
  • /bored (other / fun): Activity generator to cure boredom via Bored API v2 and internal 9-theme curated engine (/bored [type: Category] [participants: Number]).
  • /poll (other / utilities): Multi-choice interactive poll generator with Discord button voting, single/multi-vote tracking, and live ASCII progress bars (/poll question: ... options: ...).
  • Documentation Alignment: Updated README.md and wiki/Commands-Reference.md to document all 75 slash commands with exact option signatures.

🧪 Verification & Status

  • Type Safety & Build: All packages verified with 0 errors (@master-bot/auth, @master-bot/api, @master-bot/bot, @master-bot/dashboard).
  • Runtime Verification: Tested and confirmed operational.

🔗 Pushed Commits

  • fb686a0feat(bot): restore legacy commands and modernize slash command suite

@PhantomNimbi

Copy link
Copy Markdown
Author

🚀 PR Update: Deferred Interaction Lifecycle & Music Embed Streamlining

Resolved Discord interaction lifecycle handling across asynchronous commands and streamlined music embed formatting.


📦 Key Enhancements

  • Deferred Interaction Lifecycle:
    • Replaced improper interaction.followUp calls with interaction.editReply across /play, playlist commands (create-playlist, delete-playlist, display-playlist, my-playlists, remove-from-playlist, save-to-playlist), /lyrics, /game-search, /reddit, and /tv-show-search.
    • Fixes Unknown interaction token expiration exceptions on deferred slash commands.
  • Music Embed Formatting:
    • Cleaned up NowPlayingEmbed to display standard, reliable Duration field formatting (:stopwatch: 3:45 or :red_circle: Live Stream) without redundant API polling.
    • Removed redundant standalone /now-playing slash command, aligning codebase to 74 production slash commands.
  • Documentation & Reference Sync:
    • Updated README.md and wiki/Commands-Reference.md to accurately reflect the 74 active slash commands.

🧪 Verification & Status

  • Type Safety & Build: All packages verified with 0 errors (@master-bot/auth, @master-bot/api, @master-bot/dashboard, @master-bot/bot).

🔗 Pushed Commits

  • dde449efix(bot): resolve deferred interaction lifecycle and streamline music embeds

@PhantomNimbi

Copy link
Copy Markdown
Author

🚀 PR Update: Live Interactive Music Embed & Real-Time Progress Bar

Added real-time ASCII progress bar visualization and a background auto-updater to the channel now-playing music embed, along with hardened interaction error handling across slash commands.


📦 Key Enhancements

  • Live ASCII Progress Bar:
    • Implemented dynamic progress bar rendering (00:00 ▰▰▰▰▰▰▱▱▱▱▱ 03:45) in NowPlayingEmbed.ts.
    • Added intelligent livestream fallback (🔴 LIVE STREAM) for unseekable radio and video feeds.
  • Embed Progress Auto-Updater:
    • Implemented a 5-second interval progress updater in buttonHandler.ts that smoothly advances the player embed during playback.
    • Added automatic interval cleanup on pause, stop, skip, and channel cleanup via stopProgressUpdater in buttonsCollector.ts.
  • Hardened Interaction Reply Handling:
    • Added robust reply fallback handling in play.ts to gracefully handle interaction token timeouts without unhandled exceptions.
  • Documentation Synchronization:

🧪 Verification & Status

  • Type Safety & Build: Verified all packages (@master-bot/auth, @master-bot/api, @master-bot/dashboard, @master-bot/bot) with 0 errors.
  • Git Hygiene: Verified zero untracked runtime secrets or local logs via git check-ignore.

🔗 Pushed Commits

  • fe91b8dfeat(music): add live ascii progress bar and auto-updating player embed

@PhantomNimbi

Copy link
Copy Markdown
Author

🚀 PR Update: Documentation Polish, Cross-Platform Wiki Guides & Final Monorepo Hardening

Final milestone update consolidating comprehensive Wiki guides, standardized contributing workflows, cross-platform OS setup documentation, NewsAPI & Feature Flags references, and live music progress bar enhancements.


📦 Key Enhancements

  • Live Music Player & Dynamic Progress Bar:
    • Restored real-time ASCII progress bar (00:00 ▰▰▰▰▰▰▱▱▱▱▱ 03:45) in nowPlayingEmbed.ts with livestream fallback (🔴 LIVE STREAM).
    • Added background 5-second interval progress updater in buttonHandler.ts with automated timer cleanup on stop/pause/skip.
  • Contributing Guidelines (CONTRIBUTING.md):
    • Added comprehensive, professional contribution guidelines covering monorepo architecture, development prerequisites, branching strategy, validation commands, and Conventional Commits reference.
  • Cross-Platform OS Setup (Windows, macOS, Linux):
    • Documented prerequisites and background service management across Windows (winget, WSL, Memurai), macOS (brew, JVM symlinks), and Linux (apt, pacman, dnf) in Setup-and-Deployment.md.
  • 🟣 Heroku Deployment Guide:
    • Created dedicated production deployment guide (Heroku-Deployment.md) covering Node.js buildpack and Docker container (heroku.yml) configurations, Heroku Postgres & Redis add-on setup, dyno scaling, and external Lavalink voice routing.
  • NewsAPI & Dynamic Feature Flags:
    • Added NewsAPI setup documentation and dynamic feature flags reference (LAVA_ENABLED, GIFS_ENABLED, TWITCH_ENABLED, NEWS_ENABLED, IGDB_ENABLED) to API-Keys.md.
  • Application Documentation & Hygiene:
    • Created dedicated apps/bot/README.md documenting bot architecture, 74 slash commands, listeners, and preconditions.
    • Streamlined descriptions across all markdown documents to cleanly describe Master-Bot as a Discord Bot with a Next.js Web Dashboard.
    • Formatted LICENSE.md and aligned all repository references.

🧪 Verification & Status

  • Type Safety & Build: All packages verified with 0 errors (@master-bot/auth, @master-bot/api, @master-bot/dashboard, @master-bot/bot).
  • Documentation & Link Integrity: Verified 100% link resolution and command coverage across all Wiki guides and READMEs.
  • Git Hygiene: Verified zero untracked runtime secrets or local logs via git check-ignore.

🔗 Pushed Commits

  • c1c09c1docs: rename LICENSE to LICENSE.md and format with markdown
  • 243ac33docs: audit markdown documentation and add apps/bot README
  • 7e4a0b8docs(wiki): add detailed Heroku deployment and cloud hosting guide
  • 6a87c72docs: streamline discord bot and dashboard descriptions across documentation
  • 6cd8b92docs(wiki): add macOS, Windows, and Linux setup and prerequisite guides
  • fe6caefdocs: add CONTRIBUTING.md guidelines and link in README
  • 89d8205docs: fix tick formatting in contributors section and update badges
  • fe91b8dfeat(music): add live ascii progress bar and auto-updating player embed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant