UNPKG

@twurple/eventsub-base

Version:

Base for the other Twurple EventSub packages

62 lines (61 loc) 2.15 kB
import { __decorate } from "tslib"; import { checkRelationAssertion, rawDataSymbol, rtfm } from '@twurple/common'; import { EventSubChannelChatBaseNotificationEvent } from './EventSubChannelChatBaseNotificationEvent.js'; /** * An EventSub event representing a sub gift notification in a channel's chat. */ let EventSubChannelChatSubGiftNotificationEvent = class EventSubChannelChatSubGiftNotificationEvent extends EventSubChannelChatBaseNotificationEvent { type = 'sub_gift'; /** * The tier of the subscription. */ get tier() { return this[rawDataSymbol].sub_gift.sub_tier; } /** * The number of months the subscription is for. */ get durationMonths() { return this[rawDataSymbol].sub_gift.duration_months || 1; } /** * The amount of gifts that the gifter has sent in total, or `null` the gift is anonymous. */ get cumulativeAmount() { return this[rawDataSymbol].sub_gift.cumulative_total; } /** * The ID of the recipient. */ get recipientId() { return this[rawDataSymbol].sub_gift.recipient_user_id; } /** * The username of the recipient. */ get recipientName() { return this[rawDataSymbol].sub_gift.recipient_user_login; } /** * The display name of the recipient. */ get recipientDisplayName() { return this[rawDataSymbol].sub_gift.recipient_user_name; } /** * Gets more information about the recipient. */ async getRecipient() { return checkRelationAssertion(await this._client.users.getUserById(this[rawDataSymbol].sub_gift.recipient_user_id)); } /** * The id of the community gift the sub gift belongs to, or `null` if it doesn't belong to any community gift. */ get communityGiftId() { return this[rawDataSymbol].sub_gift.community_gift_id; } }; EventSubChannelChatSubGiftNotificationEvent = __decorate([ rtfm('eventsub-base', 'EventSubChannelChatSubGiftNotificationEvent', 'broadcasterId') ], EventSubChannelChatSubGiftNotificationEvent); export { EventSubChannelChatSubGiftNotificationEvent };