UNPKG

@fnlb-project/fnbr

Version:

A library to interact with Epic Games' Fortnite HTTP and XMPP services

54 lines 2.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const Endpoints_1 = tslib_1.__importDefault(require("../../../resources/Endpoints")); const PartyInvitationExpiredError_1 = tslib_1.__importDefault(require("../../exceptions/PartyInvitationExpiredError")); const BasePartyInvitation_1 = tslib_1.__importDefault(require("./BasePartyInvitation")); const enums_1 = require("../../../resources/enums"); /** * Represents a recieved party invitation */ class ReceivedPartyInvitation extends BasePartyInvitation_1.default { /** * @param client The main client * @param party The party this invitation belongs to * @param sender The friend (or the client user) who sent this invitation * @param receiver The friend (or the client user) who received this invitation * @param data The invitation data */ constructor(client, party, sender, receiver, data) { super(client, party, sender, receiver, data); this.sender = sender; this.receiver = receiver; } /** * Accepts this invitation * @throws {PartyInvitationExpiredError} The invitation already got accepted or declined * @throws {EpicgamesAPIError} */ async accept() { if (this.isExpired || this.isHandled) throw new PartyInvitationExpiredError_1.default(); await this.party.join(); this.isHandled = true; await this.client.http.epicgamesRequest({ method: 'DELETE', url: `${Endpoints_1.default.BR_PARTY}/user/${this.client.user.self.id}/pings/${this.sender.id}`, }, enums_1.AuthSessionStoreKey.Fortnite); } /** * Declines this invitation * @throws {PartyInvitationExpiredError} The invitation already got accepted or declined */ async decline() { if (this.isExpired || this.isHandled) throw new PartyInvitationExpiredError_1.default(); await this.client.http.epicgamesRequest({ method: 'DELETE', url: `${Endpoints_1.default.BR_PARTY}/user/${this.client.user.self.id}/pings/${this.sender.id}`, }, enums_1.AuthSessionStoreKey.Fortnite); this.isHandled = true; } } exports.default = ReceivedPartyInvitation; //# sourceMappingURL=ReceivedPartyInvitation.js.map