UNPKG

@twurple/eventsub-base

Version:

Base for the other Twurple EventSub packages

134 lines (133 loc) 4.76 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EventSubChannelHypeTrainBeginV2Event = 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 a Hype Train starting in a channel. */ let EventSubChannelHypeTrainBeginV2Event = class EventSubChannelHypeTrainBeginV2Event 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 EventSubChannelHypeTrainBeginV2Event#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 EventSubChannelHypeTrainBeginV2Event#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 all-time high level this type of Hype Train has reached for this broadcaster. */ get allTimeHighLevel() { return this[common_1.rawDataSymbol].all_time_high_level; } /** * The all-time high total this type of Hype Train has reached for this broadcaster. */ get allTimeHighTotal() { return this[common_1.rawDataSymbol].all_time_high_total; } /** * 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.EventSubChannelHypeTrainBeginV2Event = EventSubChannelHypeTrainBeginV2Event; tslib_1.__decorate([ (0, shared_utils_1.Enumerable)(false) ], EventSubChannelHypeTrainBeginV2Event.prototype, "_client", void 0); exports.EventSubChannelHypeTrainBeginV2Event = EventSubChannelHypeTrainBeginV2Event = tslib_1.__decorate([ (0, common_1.rtfm)('eventsub-base', 'EventSubChannelHypeTrainBeginV2Event', 'broadcasterId') ], EventSubChannelHypeTrainBeginV2Event);