UNPKG

@twurple/eventsub-base

Version:

Base for the other Twurple EventSub packages

122 lines (121 loc) 4.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EventSubChannelHypeTrainProgressV2Event = void 0; const tslib_1 = require("tslib"); const shared_utils_1 = require("@d-fischer/shared-utils"); const common_1 = require("@twurple/common"); const EventSubChannelHypeTrainContribution_1 = require("./common/EventSubChannelHypeTrainContribution"); const EventSubChannelHypeTrainSharedParticipant_1 = require("./common/EventSubChannelHypeTrainSharedParticipant"); /** * An EventSub event representing progress towards the Hype Train goal. */ let EventSubChannelHypeTrainProgressV2Event = class EventSubChannelHypeTrainProgressV2Event extends common_1.DataObject { /** @internal */ constructor(data, client) { super(data); this._client = client; } /** * The ID of the Hype Train. */ get id() { return this[common_1.rawDataSymbol].id; } /** * The ID of the broadcaster. */ get broadcasterId() { return this[common_1.rawDataSymbol].broadcaster_user_id; } /** * The name of the broadcaster. */ get broadcasterName() { return this[common_1.rawDataSymbol].broadcaster_user_login; } /** * The display name of the broadcaster. */ get broadcasterDisplayName() { return this[common_1.rawDataSymbol].broadcaster_user_name; } /** * Gets more information about the broadcaster. */ async getBroadcaster() { return (0, common_1.checkRelationAssertion)(await this._client.users.getUserById(this[common_1.rawDataSymbol].broadcaster_user_id)); } /** * The type of the Hype Train. */ get type() { return this[common_1.rawDataSymbol].type; } /** * The level the Hype Train started on. */ get level() { return this[common_1.rawDataSymbol].level; } /** * The total points already contributed to the Hype Train. */ get total() { return this[common_1.rawDataSymbol].total; } /** * The number of points contributed to the Hype Train at the current level. */ get progress() { return this[common_1.rawDataSymbol].progress; } /** * The number of points required to reach the next level. */ get goal() { return this[common_1.rawDataSymbol].goal; } /** * The contributors with the most points contributed. */ get topContributors() { return this[common_1.rawDataSymbol].top_contributions.map(data => new EventSubChannelHypeTrainContribution_1.EventSubChannelHypeTrainContribution(data, this._client)); } /** * Indicates if the Hype Train is shared. * * When `true`, {@link EventSubChannelHypeTrainProgressV2Event#sharedTrainParticipants} will contain the list of * broadcasters the train is shared with. */ get isSharedTrain() { return this[common_1.rawDataSymbol].is_shared_train; } /** * The list of broadcasters in the shared Hype Train. * * Empty if {@link EventSubChannelHypeTrainProgressV2Event#isSharedTrain} is `false`. */ get sharedTrainParticipants() { var _a; return ((_a = (0, shared_utils_1.mapNullable)(this[common_1.rawDataSymbol].shared_train_participants, data => data.map(participant => new EventSubChannelHypeTrainSharedParticipant_1.EventSubChannelHypeTrainSharedParticipant(participant, this._client)))) !== null && _a !== void 0 ? _a : []); } /** * The time when the Hype Train started. */ get startDate() { return new Date(this[common_1.rawDataSymbol].started_at); } /** * The time when the Hype Train is expected to expire, unless a change of level occurs to extend the expiration. */ get expiryDate() { return new Date(this[common_1.rawDataSymbol].expires_at); } }; exports.EventSubChannelHypeTrainProgressV2Event = EventSubChannelHypeTrainProgressV2Event; tslib_1.__decorate([ (0, shared_utils_1.Enumerable)(false) ], EventSubChannelHypeTrainProgressV2Event.prototype, "_client", void 0); exports.EventSubChannelHypeTrainProgressV2Event = EventSubChannelHypeTrainProgressV2Event = tslib_1.__decorate([ (0, common_1.rtfm)('eventsub-base', 'EventSubChannelHypeTrainProgressV2Event', 'broadcasterId') ], EventSubChannelHypeTrainProgressV2Event);