import { type NextRequest, NextResponse } from 'next/server';
import { requireGuildAccess, toApiErrorResponse } from '@/lib/auth';
import { listCommandOverridesDashboard } from '@/lib/module-configs/commands';

interface RouteParams {
  params: Promise<{ guildId: string }>;
}

export async function GET(_request: NextRequest, { params }: RouteParams) {
  const { guildId } = await params;
  try {
    await requireGuildAccess(guildId);
    const commands = await listCommandOverridesDashboard(guildId);
    return NextResponse.json({ commands });
  } catch (error) {
    return toApiErrorResponse(error);
  }
}
