UNPKG

@twurple/eventsub-base

Version:

Base for the other Twurple EventSub packages

81 lines (80 loc) 3.02 kB
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 another channel's chat during a shared chat session. */ let EventSubChannelChatSharedChatResubNotificationEvent = class EventSubChannelChatSharedChatResubNotificationEvent extends EventSubChannelChatBaseNotificationEvent { type = 'shared_chat_resub'; /** * The tier of the subscription. */ get tier() { return this[rawDataSymbol].shared_chat_resub.sub_tier; } /** * Whether the subscription was "paid" for using Prime Gaming. */ get isPrime() { return this[rawDataSymbol].shared_chat_resub.is_prime; } /** * The number of months the subscription is for. */ get durationMonths() { return this[rawDataSymbol].shared_chat_resub.duration_months || 1; } /** * The total number of months the user has subscribed for. */ get cumulativeMonths() { return this[rawDataSymbol].shared_chat_resub.cumulative_months; } /** * The streak amount of months the user has been subscribed for, or `null` if not shared. */ get streakMonths() { return this[rawDataSymbol].shared_chat_resub.streak_months ?? null; } /** * Whether the resub was gifted by another user. */ get isGift() { return this[rawDataSymbol].shared_chat_resub.is_gift; } /** * Whether the gifter is anonymous, or `null` if this is not a gift. */ get isGifterAnonymous() { return this[rawDataSymbol].shared_chat_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].shared_chat_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].shared_chat_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].shared_chat_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].shared_chat_resub.gifter_user_id, async (id) => await this._client.users.getUserById(id)); } }; EventSubChannelChatSharedChatResubNotificationEvent = __decorate([ rtfm('eventsub-base', 'EventSubChannelChatSharedChatResubNotificationEvent', 'broadcasterId') ], EventSubChannelChatSharedChatResubNotificationEvent); export { EventSubChannelChatSharedChatResubNotificationEvent };