UNPKG

@twurple/eventsub-base

Version:

Base for the other Twurple EventSub packages

101 lines (100 loc) 3.05 kB
import { __decorate } from "tslib"; import { Enumerable, mapNullable } from '@d-fischer/shared-utils'; import { checkRelationAssertion, DataObject, rawDataSymbol, rtfm } from '@twurple/common'; import { EventSubChannelBitsUsePowerUp } from './common/EventSubChannelBitsUsePowerUp.js'; /** * An EventSub event representing bits being used in a channel. */ let EventSubChannelBitsUseEvent = class EventSubChannelBitsUseEvent extends DataObject { /** @internal */ _client; /** @internal */ constructor(data, client) { super(data); this._client = client; } /** * The ID of the broadcaster in whose channel the bits were used. */ get broadcasterId() { return this[rawDataSymbol].broadcaster_user_id; } /** * The name of the broadcaster in whose channel the bits were used. */ get broadcasterName() { return this[rawDataSymbol].broadcaster_user_login; } /** * The display name of the broadcaster in whose channel the bits were used. */ get broadcasterDisplayName() { return this[rawDataSymbol].broadcaster_user_name; } /** * Gets more information about the broadcaster. */ async getBroadcaster() { return checkRelationAssertion(await this._client.users.getUserById(this[rawDataSymbol].broadcaster_user_id)); } /** * The ID of the user who has used bits. */ get userId() { return this[rawDataSymbol].user_id; } /** * The name of the user who has used bits. */ get userName() { return this[rawDataSymbol].user_login; } /** * The display name of the user who has used bits. */ get userDisplayName() { return this[rawDataSymbol].user_name; } /** * Gets more information about the user. */ async getUser() { return checkRelationAssertion(await this._client.users.getUserById(this[rawDataSymbol].user_id)); } /** * The type of the bits usage. */ get type() { return this[rawDataSymbol].type; } /** * The number of bits used. */ get bits() { return this[rawDataSymbol].bits; } /** * The chat message in plain text, or `null` if it's not applicable. */ get messageText() { return this[rawDataSymbol].message?.text ?? null; } /** * Ordered list of chat message fragments, or `null` if it's not applicable. */ get messageParts() { return this[rawDataSymbol].message?.fragments ?? null; } /** * The Power-up data, or `null` if it's not applicable. */ get powerUp() { return mapNullable(this[rawDataSymbol].power_up, v => new EventSubChannelBitsUsePowerUp(v)); } }; __decorate([ Enumerable(false) ], EventSubChannelBitsUseEvent.prototype, "_client", void 0); EventSubChannelBitsUseEvent = __decorate([ rtfm('eventsub-base', 'EventSubChannelBitsUserEvent', 'userId') ], EventSubChannelBitsUseEvent); export { EventSubChannelBitsUseEvent };