UNPKG

@twurple/eventsub-base

Version:

Base for the other Twurple EventSub packages

105 lines (104 loc) 3.81 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EventSubChannelAutomaticRewardRedemptionAddV2Event = void 0; const tslib_1 = require("tslib"); const shared_utils_1 = require("@d-fischer/shared-utils"); const common_1 = require("@twurple/common"); const EventSubChannelAutomaticReward_1 = require("./common/EventSubChannelAutomaticReward"); /** * An EventSub event representing an automatic reward being redeemed by a user in a channel. */ let EventSubChannelAutomaticRewardRedemptionAddV2Event = class EventSubChannelAutomaticRewardRedemptionAddV2Event extends common_1.DataObject { /** @internal */ constructor(data, client) { super(data); this._client = client; } /** * The ID of the redemption. */ get id() { return this[common_1.rawDataSymbol].id; } /** * The ID of the broadcaster in whose channel the reward was redeemed. */ get broadcasterId() { return this[common_1.rawDataSymbol].broadcaster_user_id; } /** * The name of the broadcaster in whose channel the reward was redeemed. */ get broadcasterName() { return this[common_1.rawDataSymbol].broadcaster_user_login; } /** * The display name of the broadcaster in whose channel the reward was redeemed. */ 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 ID of the redeeming user. */ get userId() { return this[common_1.rawDataSymbol].user_id; } /** * The name of the redeeming user. */ get userName() { return this[common_1.rawDataSymbol].user_login; } /** * The display name of the redeeming user. */ get userDisplayName() { return this[common_1.rawDataSymbol].user_name; } /** * Gets more information about the redeeming user. */ async getUser() { return (0, common_1.checkRelationAssertion)(await this._client.users.getUserById(this[common_1.rawDataSymbol].user_id)); } /** * An object that contains the reward information. */ get reward() { return new EventSubChannelAutomaticReward_1.EventSubChannelAutomaticReward(this[common_1.rawDataSymbol].reward); } /** * The text of the message, or `null` if there is no message. */ get messageText() { var _a, _b; return (_b = (_a = this[common_1.rawDataSymbol].message) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : null; } /** * The pre-parsed message parts. */ get messageParts() { var _a, _b; return (_b = (_a = this[common_1.rawDataSymbol].message) === null || _a === void 0 ? void 0 : _a.fragments) !== null && _b !== void 0 ? _b : []; } /** * The date when the user redeemed the reward. */ get redemptionDate() { return new Date(this[common_1.rawDataSymbol].redeemed_at); } }; exports.EventSubChannelAutomaticRewardRedemptionAddV2Event = EventSubChannelAutomaticRewardRedemptionAddV2Event; tslib_1.__decorate([ (0, shared_utils_1.Enumerable)(false) ], EventSubChannelAutomaticRewardRedemptionAddV2Event.prototype, "_client", void 0); exports.EventSubChannelAutomaticRewardRedemptionAddV2Event = EventSubChannelAutomaticRewardRedemptionAddV2Event = tslib_1.__decorate([ (0, common_1.rtfm)('eventsub-base', 'EventSubChannelAutomaticRewardRedemptionAddV2Event', 'id') ], EventSubChannelAutomaticRewardRedemptionAddV2Event);