@twurple/eventsub-base
Version:
Base for the other Twurple EventSub packages
81 lines (80 loc) • 2.78 kB
JavaScript
import { __decorate } from "tslib";
import { mapNullable } from '@d-fischer/shared-utils';
import { rawDataSymbol, rtfm } from '@twurple/common';
import { EventSubChannelChatBaseNotificationEvent } from './EventSubChannelChatBaseNotificationEvent.js';
/**
* An EventSub event representing a resub notification in a channel's chat.
*/
let EventSubChannelChatResubNotificationEvent = class EventSubChannelChatResubNotificationEvent extends EventSubChannelChatBaseNotificationEvent {
type = 'resub';
/**
* The tier of the subscription.
*/
get tier() {
return this[rawDataSymbol].resub.sub_tier;
}
/**
* Whether the subscription was "paid" for using Prime Gaming.
*/
get isPrime() {
return this[rawDataSymbol].resub.is_prime;
}
/**
* The number of months the subscription is for.
*/
get durationMonths() {
return this[rawDataSymbol].resub.duration_months || 1;
}
/**
* The total number of months the user has subscribed for.
*/
get cumulativeMonths() {
return this[rawDataSymbol].resub.cumulative_months;
}
/**
* The streak amount of months the user has been subscribed for, or `null` if not shared.
*/
get streakMonths() {
return this[rawDataSymbol].resub.streak_months ?? null;
}
/**
* Whether the resub was gifted by another user.
*/
get isGift() {
return this[rawDataSymbol].resub.is_gift;
}
/**
* Whether the gifter is anonymous, or `null` if this is not a gift.
*/
get isGifterAnonymous() {
return this[rawDataSymbol].resub.gifter_is_anonymous ?? null;
}
/**
* The ID of the gifter, or `null` if they're anonymous or this is not a gift.
*/
get gifterId() {
return this[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[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[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 mapNullable(this[rawDataSymbol].resub.gifter_user_id, async (id) => await this._client.users.getUserById(id));
}
};
EventSubChannelChatResubNotificationEvent = __decorate([
rtfm('eventsub-base', 'EventSubChannelChatSubNotificationEvent', 'broadcasterId')
], EventSubChannelChatResubNotificationEvent);
export { EventSubChannelChatResubNotificationEvent };