import { EventEmitter } from 'events'; import Auth from './auth/Auth'; import Http from './http/HTTP'; import AsyncLock from './util/AsyncLock'; import XMPP from './xmpp/XMPP'; import Friend from './structures/friend/Friend'; import CreatorCode from './structures/CreatorCode'; import ClientParty from './structures/party/ClientParty'; import Party from './structures/party/Party'; import RadioStation from './structures/RadioStation'; import SentPartyJoinRequest from './structures/party/SentPartyJoinRequest'; import Stats from './structures/Stats'; import FortniteServerStatus from './structures/FortniteServerStatus'; import EpicgamesServerStatus from './structures/EpicgamesServerStatus'; import TournamentManager from './managers/TournamentManager'; import UserManager from './managers/UserManager'; import FriendManager from './managers/FriendManager'; import STWManager from './managers/STWManager'; import EOSPartyManager from './managers/EOSPartyManager'; import STOMP from './stomp/STOMP'; import ChatManager from './managers/ChatManager'; import type { CreativeIslandData, CreativeDiscoveryPanel } from '../resources/httpResponses'; import type { ClientOptions, ClientConfig, ClientEvents, FortnitePartyConfig, Schema, Region, BlurlStream, Language, FortnitePartyData, PresenceOnlineType, BRAccountLevelData } from '../resources/structs'; /** * Represents the main client */ declare class Client extends EventEmitter { /** * Timeouts set by {@link Client#setTimeout} that are still active */ private timeouts; /** * Intervals set by {@link Client#setInterval} that are still active */ private intervals; /** * All client configuration options */ config: ClientConfig; /** * Authentication manager */ auth: Auth; /** * Lock used to pause certain incoming xmpp messages while the bots party is being modified */ partyLock: AsyncLock; /** * Lock used to pause xmpp presences while the friend caches are being populated */ cacheLock: AsyncLock; /** * HTTP manager */ http: Http; /** * User manager */ user: UserManager; /** * Whether the client is fully started */ isReady: boolean; /** * XMPP manager */ xmpp: XMPP; /** * EOS Connect STOMP manager */ stomp: STOMP; /** * EOS Party v2 REST manager */ eosParty: EOSPartyManager; /** * Friend manager */ friend: FriendManager; /** * The client's current party */ party?: ClientParty; /** * The client's tournament manager. */ tournaments: TournamentManager; /** * The last saved client party member meta */ lastPartyMemberMeta?: Schema; /** * Fortnite: Save The World manager */ stw: STWManager; /** * EOS: Chat Manager */ chat: ChatManager; /** * Timer for keeping the EOS Party connection alive */ private eosPartyKeepAliveTimer?; private statusUpdateTimer?; private partyRecovery?; /** * @param config The client's configuration options */ constructor(config?: ClientOptions); on(event: U, listener: ClientEvents[U]): this; once(event: U, listener: ClientEvents[U]): this; emit(event: U, ...args: Parameters): boolean; /** * Logs the client in. * A valid authentication method must be provided in the client's config. * By default, there will be a console prompt asking for an authorization code * @throws {EpicgamesAPIError} */ login(): Promise; /** * Logs out, clears local state, and emits `disconnected` even if token revocation fails. */ logout(): Promise; /** * Restarts the client */ restart(): Promise; /** * Initializes {@link Client#party} * @param createNew Whether to create a new party * @param forceNew Whether to force create a new party */ initParty(createNew?: boolean, forceNew?: boolean): Promise; /** * Restores a previously existing party, creating one with client defaults if it is gone. */ recoverParty(hadParty: boolean): Promise; /** * Waits until the client is ready * @param timeout How long to wait for until an error is thrown */ waitUntilReady(timeout?: number): Promise; /** * Cleanup method */ private destroy; /** * Initializes the sweeping of cached objects */ private initCacheSweeping; /** * Updates the client's caches */ updateCaches(): Promise; /** * Removes presences from the client's cache that are older than the max lifetime * @param maxLifetime How old a presence cache entry must be before it can be sweeped (in seconds) * @returns The amount of presences sweeped */ sweepPresences(maxLifetime?: number | undefined): number; /** * Removes users from the client's cache that are older than the max lifetime * @param maxLifetime How old a user cache entry must be before it can be sweeped (in seconds) * @returns The amount of users sweeped */ sweepUsers(maxLifetime?: number | undefined): number; /** * Wait until an event is emitted * @param event The event that will be waited for * @param timeout The timeout (in milliseconds) * @param filter The filter for the event */ waitForEvent(event: U, timeout?: number, filter?: (...args: Parameters) => boolean): Promise>; /** * Waits for a friend to be added to the client's cache * @param id The friend's account ID */ waitForFriend(id: string): Promise; /** * Sets a timeout that will be automatically cancelled if the client is logged out * @param fn Function to execute * @param delay Time to wait before executing (in milliseconds) * @param args Arguments for the function */ setTimeout(fn: (...args: any) => any, delay: number, ...args: any): NodeJS.Timeout; /** * Clears a timeout * @param timeout Timeout to cancel */ clearTimeout(timeout: NodeJS.Timeout): void; /** * Sets an interval that will be automatically cancelled if the client is logged out * @param fn Function to execute * @param delay Time to wait between executions (in milliseconds) * @param args Arguments for the function */ setInterval(fn: (...args: any) => any, delay: number, ...args: any): NodeJS.Timeout; /** * Clears an interval. * @param interval Interval to cancel */ clearInterval(interval: NodeJS.Timeout): void; static consoleQuestion(question: string): Promise; /** * Debug a message using the methods set in the client config * @param message Text to debug * @param type Debug type (regular, http or xmpp) */ debug(message: string, type?: 'regular' | 'http' | 'xmpp' | 'stomp'): void; /** * Sets the clients status * @param status The status * @param onlineType The presence's online type (eg "away") * @throws {FriendNotFoundError} The user does not exist or is not friends with the client */ setStatus(status?: string, onlineType?: PresenceOnlineType): Promise; /** * Resets the client's status and online type */ resetStatus(): Promise; /** * Sends a party invitation to a friend * @param friend The friend that will receive the invitation * @throws {FriendNotFoundError} The user does not exist or is not friends with the client * @throws {PartyAlreadyJoinedError} The user is already a member of this party * @throws {PartyMaxSizeReachedError} The party reached its max size * @throws {PartyNotFoundError} The client is not in party * @throws {EpicgamesAPIError} */ invite(friend: string): Promise; /** * Joins an EOS Party v2 social party by EOS ID or linked lobby ID. * @param fnIdOrEOSId The EOS Party ID or Fortnite lobby ID */ joinParty(fnIdOrEOSId: string): Promise; /** * Creates a linked EOS social party and Fortnite lobby. */ createParty(config?: FortnitePartyConfig): Promise; /** * Leaves the current party. * @param createNew Whether to create a replacement party * @throws {PartyNotFoundError} The client is not in a party */ leaveParty(createNew?: boolean): Promise; /** * Leaves the current EOS and / or Fortnite party even if the local state was lost */ destroyParty(): Promise; /** * Sends a party join request to a friend. * @param friend The friend that will receive the request * @throws {FriendNotFoundError} The user does not exist or is not friends with the client * @throws {EpicgamesAPIError} */ sendRequestToJoin(friend: string): Promise; /** * Fetches the client's party * @throws {EpicgamesAPIError} */ getClientParty(): Promise; /** * Fetches raw Fortnite lobby data by Fortnite lobby * @param id The Fortnite lobby ID * @throws {PartyNotFoundError} The party wasn't found * @throws {PartyPermissionError} The party cannot be fetched due to a permission error * @throws {EpicgamesAPIError} */ getRawFortniteParty(id: string): Promise; /** * Fetches a party by its Fortnite lobby or EOS Party ID * @param fnOrEOSId The Fortnite lobby ID or EOS Party ID * @throws {PartyNotFoundError} The party wasn't found * @throws {PartyPermissionError} The party cannot be fetched due to a permission error * @throws {EpicgamesAPIError} */ getParty(fnOrEOSId: string): Promise; private requireEOSPartyConnections; private resolvePartyConfig; private startEOSPartyKeepAlive; /** * Fetches the current Fortnite party build ID from matchmaking. * @throws {EpicgamesAPIError} */ fetchPartyBuildId(): Promise; /** * Fetches the current Fortnite server status (lightswitch) * @throws {EpicgamesAPIError} */ getFortniteServerStatus(): Promise; /** * Fetches the current epicgames server status (https://status.epicgames.com/) * @throws {AxiosError} */ getEpicgamesServerStatus(): Promise; /** * Fetches the current Fortnite storefronts * @param language The language * @throws {EpicgamesAPIError} */ getStorefronts(language?: Language): Promise; /** * Downloads a blurl stream (eg a radio station stream or a news video) * @param id The stream ID * @throws {AxiosError} */ downloadBlurlStream(id: string): Promise; getBRStats(user: string, startTime?: number, endTime?: number): Promise; getBRStats(user: string[], startTime?: number, endTime?: number, stats?: string[]): Promise; /** * Fetches the current Battle Royale news * @param language The language of the news * @param customPayload Extra data to send in the request body for a personalized news response (battle pass level, country, etc) * @throws {EpicgamesAPIError} */ getBRNews(language?: "en", customPayload?: any): Promise; /** * Fetches data for a Support-A-Creator code * @param code The Support-A-Creator code (slug) * @throws {CreatorCodeNotFoundError} The Support-A-Creator code wasnt found * @throws {EpicgamesAPIError} */ getCreatorCode(code: string): Promise; /** * Fetches the current Fortnite Battle Royale radio stations * @throws {EpicgamesAPIError} */ getRadioStations(): Promise; /** * Fetches the current Battle Royale event flags * @param language The language * @throws {EpicgamesAPIError} */ getBREventFlags(language?: Language): Promise; /** * Fetches the Battle Royale account level for one or multiple users * @param user The id(s) and/or display name(s) of the user(s) to fetch the account level for * @param seasonNumber The season number (eg. 16, 17, 18) * @throws {UserNotFoundError} The user wasn't found * @throws {StatsPrivacyError} The user set their stats to private * @throws {EpicgamesAPIError} */ getBRAccountLevel(user: string | string[], seasonNumber: number): Promise; /** * Fetches the storefront keychain * @throws {EpicgamesAPIError} */ getStorefrontKeychain(): Promise; /** * Fetches a creative island by its code * @param code The island code * @throws {CreativeIslandNotFoundError} A creative island with the provided code does not exist * @throws {EpicgamesAPIError} */ getCreativeIsland(code: string): Promise; /** * Fetches the creative discovery surface * @param gameVersion The current game version (MAJOR.MINOR) * @throws {EpicgamesAPIError} */ getCreativeDiscoveryPanels(gameVersion: string | undefined, region: Region): Promise; } export default Client;