@twurple/eventsub-base
Version:
Base for the other Twurple EventSub packages
99 lines (98 loc) • 3.24 kB
JavaScript
import { __decorate } from "tslib";
import { Enumerable } from '@d-fischer/shared-utils';
import { checkRelationAssertion, DataObject, rawDataSymbol, rtfm } from '@twurple/common';
/**
* An EventSub event representing a change in channel metadata.
*/
let EventSubChannelUpdateEvent = class EventSubChannelUpdateEvent extends DataObject {
/** @internal */ _client;
/** @internal */
constructor(data, client) {
super(data);
this._client = client;
}
/**
* The ID of the broadcaster.
*/
get broadcasterId() {
return this[rawDataSymbol].broadcaster_user_id;
}
/**
* The name of the broadcaster.
*/
get broadcasterName() {
return this[rawDataSymbol].broadcaster_user_login;
}
/**
* The display name of the broadcaster.
*/
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 title of the stream.
*/
get streamTitle() {
return this[rawDataSymbol].title;
}
/**
* The language of the stream.
*/
get streamLanguage() {
return this[rawDataSymbol].language;
}
/**
* The ID of the game that is currently being played on the channel.
*/
get categoryId() {
return this[rawDataSymbol].category_id;
}
/**
* The name of the game that is currently being played on the channel.
*/
get categoryName() {
return this[rawDataSymbol].category_name;
}
/**
* Gets more information about the game that is currently being played on the channel.
*/
async getGame() {
return this[rawDataSymbol].category_id
? checkRelationAssertion(await this._client.games.getGameById(this[rawDataSymbol].category_id))
: null;
}
/**
* Whether the channel is flagged as suitable for mature audiences only.
*
* @deprecated Use {@link EventSubChannelUpdateEvent#contentClassificationLabels} to check if any content
* classification labels are applied to the channel.
*
* Currently, this flag mimics the previous behavior by checking whether the `contentClassificationLabels`
* array is not empty.
*
* This flag will be removed in the next major release.
*/
get isMature() {
return this[rawDataSymbol].content_classification_labels.length > 0;
}
/**
* An array of content classification label IDs currently applied on the channel.
* To retrieve a list of all possible IDs, use the {@link ApiClient#contentClassificationLabels#getAll} API method.
*/
get contentClassificationLabels() {
return this[rawDataSymbol].content_classification_labels;
}
};
__decorate([
Enumerable(false)
], EventSubChannelUpdateEvent.prototype, "_client", void 0);
EventSubChannelUpdateEvent = __decorate([
rtfm('eventsub-base', 'EventSubChannelUpdateEvent', 'broadcasterId')
], EventSubChannelUpdateEvent);
export { EventSubChannelUpdateEvent };