/**
 * ╔══════════════════════════════════════════════════════════════════╗
 * ║                                                                  ║
 * ║                        +-+-+-+-+-+-+-+-+                         ║
 * ║                        |H|e|x|a|H|o|s|t|                         ║
 * ║                        +-+-+-+-+-+-+-+-+                         ║
 * ║                                                                  ║
 * ║              © 2026 HexaHost — All Rights Reserved               ║
 * ║                                                                  ║
 * ║             discord  ──  https://discord.gg/hexahost             ║
 * ║        github   ──  https://github.com/theoneandonlymace         ║
 * ║                                                                  ║
 * ╚══════════════════════════════════════════════════════════════════╝
 */
import { NextResponse } from "next/server";
import { getBotInviteUrl } from "@/lib/discord-invite";

export const dynamic = "force-dynamic";

/** Redirects to the Discord bot invite (uses DISCORD_CLIENT_ID at runtime). */
export async function GET() {
  const url = getBotInviteUrl();
  if (!url) {
    return NextResponse.json(
      {
        detail:
          "DISCORD_CLIENT_ID is not configured. Set it in the dashboard environment.",
      },
      { status: 503 }
    );
  }
  return NextResponse.redirect(url, 302);
}
