import { type NextRequest, NextResponse } from 'next/server';
import { requireGuildAccess, toApiErrorResponse } from '@/lib/auth';
import { listGuildEmojisForDashboard } from '@/lib/discord-guild-resources';

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

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