import backupFetch from 'node-fetch'; import TypedEmitter from 'typed-emitter'; import backupWebSocket from 'ws'; import ClientConsole from './Classes/ClientConsole'; import Logger from './Classes/Logger'; import UserManager from './Classes/UserManager'; import { OutgoingPacketTypes } from './Packets'; import { ClientOptions, ClientState, FriendRequest, LCUser, MCAccount, OnlineUser, PlayerStatus, User, UserState } from './Types'; declare const Client_base: new () => TypedEmitter; /** The LCLib Client */ export declare class Client extends Client_base { /** The Client Logger */ logger: Logger; /** The Client Mojang User Manager */ userManager: UserManager; WebSocket: typeof backupWebSocket; fetch: typeof backupFetch; socketURL: string; /** The State of the Client */ state: ClientState; /** Failed Login Attempts, resets on success, fail on 5 failed attempts after one successful login or 3 failed attempts before one */ private failedAttempts; /** The Client's Minecraft Account */ account: MCAccount; get uuidWithoutDashes(): string; get uuidWithDashes(): string; get uuid(): string; /** The Client's Lunar Client State */ userState: UserState; /** The currently active WebSocket */ socket: backupWebSocket; /** Whether the Client has sent the `connected` event */ sentConnected: boolean; /** Client's LC User */ user: LCUser; /** All Users that the Client has cached, mapped by their UUIDs (does not include friends, use `users` get property) */ _users: Map; /** All Users that the Client has cached, mapped by their UUIDs */ get users(): Map; /** All of the Client's Friends, mapped by their UUIDs */ friends: Map; /** All Friend Requests that are incoming or outgoing from the client, mapped by the target User UUID */ friendRequests: Map; /** All console messages, each string is a new message, in order from first created to last created */ clientConsole: ClientConsole; /** The IDs of the emotes owned and equipped (meaning shown in the menu when using the keybind) */ emotes: { owned: number[]; equipped: number[]; }; /** Whether Incoming Friend Requests are enabled for the Client User */ friendRequestsEnabled: boolean; /** Client Player Status */ status: PlayerStatus; private manuallyDisconnected; /** * The LCLib Client */ constructor(options: Partial); /** * Intiate and Login to the Client * @param access_token The Microsoft Access Token * @param minecraft_authed Whether the provided Access Token has already been authenticated with Minecraft */ init(access_token: string, minecraft_authed?: boolean): Promise; /** * Connect to the WebSocket (with auto reconnecter) * @param state User State for the Connection */ connect(state?: Partial): Promise; private _connect; /** * Send a Packet through the Socket (DON'T USE, USE `Client#sendPersistent()` OR `Client#sendImpersistent()`) * @param id The Packet ID * @param data Packet Data */ private send; /** * Send a Packet through the Socket that will be guaranteed to send, either with the current WebSocket or with the next open one * @param id The Packet ID * @param data Packet Data */ sendPersistent(id: T, data: OutgoingPacketTypes[T]): Promise; /** * Send a Packet through the Socket that will only send if there is an active connection * @param id The Packet ID * @param data Packet Data */ sendImpersistent(id: T, data: OutgoingPacketTypes[T]): Promise; /** * Send a Message to one of your friends * @param user The Friend User Object or UUID * @param message The message * @returns A promise that resolves with whether the message send was successful */ sendMessage(user: User | string, message?: string): Promise; /** * Change the Client's Server * @param server The server name (MUST BE ONE OF LUNAR CLIENT'S SERVER NAMES https://github.com/LunarClient/ServerMappings/tree/master/servers) * @returns A promise that resolves with whether it was successful */ changeServer(server: string): Promise; /** * Send a Friend Request to a User * @param data An object that must have eitehr a valid UUID or a valid Username of the User (preferably both) * @returns Whether the Friend Request was successfully sent */ sendFriendRequest(data?: { uuid?: string; username?: string; }): Promise; /** * Remove a Friend from your Friends List * @param user The Friend User Object or UUID * @returns Whether the Removal was successful */ removeFriend(user: User | string): Promise; /** * Handle a Friend Request * @param request Either the Friend Request Object or the Friend Request target User UUID * @param accepted Whether the request was accepted (default `false`) * @returns Whether the Friend Request was handled successfully */ handleFriendRequest(request: FriendRequest | string, accepted?: boolean): Promise; /** * Toggle Incoming Friend Requests * @param enabled Enabled or Disabled * @returns Whether the toggle succeded */ toggleFriendRequests(enabled: boolean): Promise; /** * Set the Client Status * @param status The Status * @returns Whether the set succeeded */ setStatus(status: PlayerStatus): Promise; /** * Await a Notification (USED INTERNALLY) * @returns The notification data as an object */ private awaitNotification; x: any; /** * Fetch all players with the UUIDs specified * * You will only recieve a response for the UUID if that user is on Lunar Client or it has been cached before, otherwise that user's data will be `null` * @param uuids The UUIDs to fetch * @returns User data for each user in the same order as the UUIDs (`null` for the user if that user is not online on Lunar Client and has never been cached) (`null` as the object if there were invalid UUIDs or it failed to fetch) */ fetchPlayers(...uuids: string[]): Promise | null>; /** * Disconnect the Client from the WebSocket */ disconnect(): void; /** * Destroy the Client and all it's data */ destroy(): void; } /** Events a Client can Emit */ export type ClientEvents = { /** The Client is connected (sent once) */ connected(): void; /** The Client is connected (sent every connection) */ open(): void; /** The Client has been logged into with an invalid access token and requires the `init()` method to be run again to re-login */ invalid(): void; /** The Client has been manually disconnected and requires the `connect()` method to be run again to reconnect */ disconnected(): void; /** A Notification has been recieved from the WebSocket */ notification(title: string | null, message: string): void; /** The server has told us to intitate a Force Crash */ forceCrash(): void; /** The server has sent us a message to put in the "Chat" */ chatMessage(message: string): void; /** A player is playing an emote */ playEmote(user: OnlineUser, emoteID: number, metadata: number): void; /** A player has been updated or added to the cache */ playerUpdate(user: User): void; /** A new friend request has been created (incoming OR outgoing) */ friendRequest(request: FriendRequest): void; /** A Friend Request has been handled */ friendRequestHandled(request: FriendRequest, accepted: boolean): void; /** A Message has been recieved from a Friend */ friendMessage(user: User, message: string): void; /** A friend of yours has removed you */ friendRemove(user: User): void; }; export {};