UNPKG

fnbr

Version:

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

83 lines 3.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const util_1 = require("util"); const Base_1 = tslib_1.__importDefault(require("../../Base")); const AsyncLock_1 = tslib_1.__importDefault(require("../../util/AsyncLock")); const PartyMessage_1 = tslib_1.__importDefault(require("./PartyMessage")); const PartyChatConversationNotFoundError_1 = tslib_1.__importDefault(require("../../exceptions/PartyChatConversationNotFoundError")); const deprecationNotOverXmppAnymore = 'Party Chat is not done over XMPP anymore, this function will be removed in a future version'; /** * Represents a party's conversation */ class PartyChat extends Base_1.default { /** * the party chat's conversation id */ get conversationId() { return `p-${this.party.id}`; } /** * @param client The main client * @param party The chat room's party */ constructor(client, party) { super(client); // xmpp legacy (only here for backwards compatibility) this.joinLock = new AsyncLock_1.default(); this.nick = ''; this.jid = ''; this.isConnected = true; this.party = party; } /** * Sends a message to this party chat * @param content The message that will be sent * @throws {PartyChatConversationNotFoundError} When the client is the only party member */ async send(content) { if (this.party.members.size < 2) { throw new PartyChatConversationNotFoundError_1.default(); } const messageId = await this.client.chat.sendMessageInConversation(this.conversationId, { body: content, }, this.party.members .map((x) => x.id)); return new PartyMessage_1.default(this.client, { author: this.party.me, content, party: this.party, id: messageId, }); } /** * Joins this party chat * @deprecated since chat is not done over xmpp anymore, this function will do nothing and will be removed in a future version */ // eslint-disable-next-line class-methods-use-this async join() { const deprecatedFn = (0, util_1.deprecate)(() => { }, deprecationNotOverXmppAnymore); return deprecatedFn(); } /** * Leaves this party chat * @deprecated since chat is not done over xmpp anymore, this function will do nothing and will be removed in a future version */ // eslint-disable-next-line class-methods-use-this async leave() { const deprecatedFn = (0, util_1.deprecate)(() => { }, deprecationNotOverXmppAnymore); return deprecatedFn(); } /** * Ban a member from this party chat * @param member The member that should be banned * @deprecated since chat is not done over xmpp anymore, this function will do nothing and will be removed in a future version */ // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars async ban(member) { const deprecatedFn = (0, util_1.deprecate)(() => { }, deprecationNotOverXmppAnymore); return deprecatedFn(); } } exports.default = PartyChat; //# sourceMappingURL=PartyChat.js.map