@twurple/eventsub-base
Version:
Base for the other Twurple EventSub packages
90 lines (89 loc) • 3.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.EventSubChannelAdBreakBeginEvent = void 0;
const tslib_1 = require("tslib");
const shared_utils_1 = require("@d-fischer/shared-utils");
const common_1 = require("@twurple/common");
/**
* An EventSub event representing an ad break beginning in a broadcaster channel.
*/
let EventSubChannelAdBreakBeginEvent = class EventSubChannelAdBreakBeginEvent extends common_1.DataObject {
/** @internal */
constructor(data, client) {
super(data);
this._client = client;
}
/**
* The broadcaster's user ID for the channel the ad was run on.
*/
get broadcasterId() {
return this[common_1.rawDataSymbol].broadcaster_user_id;
}
/**
* The broadcaster's user login for the channel the ad was run on.
*/
get broadcasterName() {
return this[common_1.rawDataSymbol].broadcaster_user_login;
}
/**
* The broadcaster's user display name for the channel the ad was run on.
*/
get broadcasterDisplayName() {
return this[common_1.rawDataSymbol].broadcaster_user_name;
}
/**
* Gets more information about the broadcaster.
*/
async getBroadcaster() {
return (0, common_1.checkRelationAssertion)(await this._client.users.getUserById(this[common_1.rawDataSymbol].broadcaster_user_id));
}
/**
* The ID of the user that requested the ad. For automatic ads, this will be the ID of the broadcaster.
*/
get requesterId() {
return this[common_1.rawDataSymbol].requester_user_id;
}
/**
* The login of the user that requested the ad.
*/
get requesterName() {
return this[common_1.rawDataSymbol].requester_user_login;
}
/**
* The display name of the user that requested the ad.
*/
get requesterDisplayName() {
return this[common_1.rawDataSymbol].requester_user_name;
}
/**
* Gets more information about the user that requested the ad.
*/
async getRequester() {
return (0, common_1.checkRelationAssertion)(await this._client.users.getUserById(this[common_1.rawDataSymbol].requester_user_id));
}
/**
* Length in seconds of the mid-roll ad break requested.
*/
get durationSeconds() {
return this[common_1.rawDataSymbol].duration_seconds;
}
/**
* The date/time when the ad break started.
*/
get startDate() {
return new Date(this[common_1.rawDataSymbol].started_at);
}
/**
* Indicates if the ad was automatically scheduled via Ads Manager.
*/
get isAutomatic() {
return this[common_1.rawDataSymbol].is_automatic;
}
};
exports.EventSubChannelAdBreakBeginEvent = EventSubChannelAdBreakBeginEvent;
tslib_1.__decorate([
(0, shared_utils_1.Enumerable)(false)
], EventSubChannelAdBreakBeginEvent.prototype, "_client", void 0);
exports.EventSubChannelAdBreakBeginEvent = EventSubChannelAdBreakBeginEvent = tslib_1.__decorate([
(0, common_1.rtfm)('eventsub-base', 'EventSubChannelAdBreakBeginEvent', 'broadcasterId')
], EventSubChannelAdBreakBeginEvent);