export interface DiscordUser {
  id: string;
  username: string;
  email: string;
  avatar?: string;
  discriminator: string;
}

export interface DiscordTokenResponse {
  access_token: string;
  token_type: string;
  expires_in: number;
  refresh_token: string;
  scope: string;
}

export const discordOAuth = {
  // 获取Discord授权URL
  getAuthUrl: (state?: string): string => {
    const params = new URLSearchParams({
      client_id: process.env.NEXT_PUBLIC_DISCORD_CLIENT_ID!,
      redirect_uri: `${window.location.origin}/api/auth/discord/callback`,
      response_type: 'code',
      scope: ['identify', 'email'].join(' '),
      ...(state && { state }),
    });

    return `https://discord.com/api/oauth2/authorize?${params.toString()}`;
  },
};
