@twurple/eventsub-base
Version:
Base for the other Twurple EventSub packages
89 lines (88 loc) • 3.36 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.EventSubChannelChatResubNotificationEvent = void 0;
const tslib_1 = require("tslib");
const shared_utils_1 = require("@d-fischer/shared-utils");
const common_1 = require("@twurple/common");
const EventSubChannelChatBaseNotificationEvent_1 = require("./EventSubChannelChatBaseNotificationEvent");
/**
* An EventSub event representing a resub notification in a channel's chat.
*/
let EventSubChannelChatResubNotificationEvent = class EventSubChannelChatResubNotificationEvent extends EventSubChannelChatBaseNotificationEvent_1.EventSubChannelChatBaseNotificationEvent {
constructor() {
super(...arguments);
this.type = 'resub';
}
/**
* The tier of the subscription.
*/
get tier() {
return this[common_1.rawDataSymbol].resub.sub_tier;
}
/**
* Whether the subscription was "paid" for using Prime Gaming.
*/
get isPrime() {
return this[common_1.rawDataSymbol].resub.is_prime;
}
/**
* The number of months the subscription is for.
*/
get durationMonths() {
return this[common_1.rawDataSymbol].resub.duration_months || 1;
}
/**
* The total number of months the user has subscribed for.
*/
get cumulativeMonths() {
return this[common_1.rawDataSymbol].resub.cumulative_months;
}
/**
* The streak amount of months the user has been subscribed for, or `null` if not shared.
*/
get streakMonths() {
var _a;
return (_a = this[common_1.rawDataSymbol].resub.streak_months) !== null && _a !== void 0 ? _a : null;
}
/**
* Whether the resub was gifted by another user.
*/
get isGift() {
return this[common_1.rawDataSymbol].resub.is_gift;
}
/**
* Whether the gifter is anonymous, or `null` if this is not a gift.
*/
get isGifterAnonymous() {
var _a;
return (_a = this[common_1.rawDataSymbol].resub.gifter_is_anonymous) !== null && _a !== void 0 ? _a : null;
}
/**
* The ID of the gifter, or `null` if they're anonymous or this is not a gift.
*/
get gifterId() {
return this[common_1.rawDataSymbol].resub.gifter_user_id;
}
/**
* The username of the gifter, or `null` if they're anonymous or this is not a gift.
*/
get gifterName() {
return this[common_1.rawDataSymbol].resub.gifter_user_login;
}
/**
* The display name of the gifter, or `null` if they're anonymous or this is not a gift.
*/
get gifterDisplayName() {
return this[common_1.rawDataSymbol].resub.gifter_user_name;
}
/**
* Gets more information about the gifter, or `null` if they're anonymous or this is not a gift.
*/
async getGifter() {
return await (0, shared_utils_1.mapNullable)(this[common_1.rawDataSymbol].resub.gifter_user_id, async (id) => await this._client.users.getUserById(id));
}
};
exports.EventSubChannelChatResubNotificationEvent = EventSubChannelChatResubNotificationEvent;
exports.EventSubChannelChatResubNotificationEvent = EventSubChannelChatResubNotificationEvent = tslib_1.__decorate([
(0, common_1.rtfm)('eventsub-base', 'EventSubChannelChatSubNotificationEvent', 'broadcasterId')
], EventSubChannelChatResubNotificationEvent);