fnbr
Version:
A library to interact with Epic Games' Fortnite HTTP and XMPP services
53 lines • 1.98 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const Endpoints_1 = tslib_1.__importDefault(require("../../../resources/Endpoints"));
const Base_1 = tslib_1.__importDefault(require("../../Base"));
const enums_1 = require("../../../resources/enums");
/**
* Represents a party member join confirmation request
*/
class PartyMemberConfirmation extends Base_1.default {
/**
* @param client The main client
* @param party The party
* @param user The user who requested to join the party
* @param data The party confirmation data
*/
constructor(client, party, user, data) {
super(client);
this.party = party;
this.user = user;
this.createdAt = new Date(data.sent);
}
/**
* Whether the join confirmation is still active (can be confirmed / rejected)
*/
get isActive() {
return this.party.pendingMemberConfirmations.has(this.user.id);
}
/**
* Accepts the member join confirmation and makes the member join the party
* @throws {EpicgamesAPIError}
*/
async confirm() {
await this.client.http.epicgamesRequest({
method: 'POST',
url: `${Endpoints_1.default.BR_PARTY}/parties/${this.party.id}/members/${this.user.id}/confirm`,
}, enums_1.AuthSessionStoreKey.Fortnite);
this.party.pendingMemberConfirmations.delete(this.user.id);
}
/**
* Rejects the member join confirmation
* @throws {EpicgamesAPIError}
*/
async reject() {
await this.client.http.epicgamesRequest({
method: 'POST',
url: `${Endpoints_1.default.BR_PARTY}/parties/${this.party.id}/members/${this.user.id}/reject`,
}, enums_1.AuthSessionStoreKey.Fortnite);
this.party.pendingMemberConfirmations.delete(this.user.id);
}
}
exports.default = PartyMemberConfirmation;
//# sourceMappingURL=PartyMemberConfirmation.js.map