@twurple/eventsub-base
Version:
Base for the other Twurple EventSub packages
36 lines (35 loc) • 1.44 kB
JavaScript
import { __decorate } from "tslib";
import { rtfm } from '@twurple/common';
import { EventSubChannelFollowEvent } from '../events/EventSubChannelFollowEvent.js';
import { EventSubSubscription } from './EventSubSubscription.js';
/** @internal */
let EventSubChannelFollowSubscription = class EventSubChannelFollowSubscription extends EventSubSubscription {
_userId;
_moderatorId;
/** @protected */ _cliName = 'follow';
constructor(handler, client, _userId, _moderatorId) {
super(handler, client);
this._userId = _userId;
this._moderatorId = _moderatorId;
}
get id() {
return `channel.follow.${this._userId}.${this._moderatorId}`;
}
get authUserId() {
return this._moderatorId;
}
transformData(data) {
return this._client._config.managed
? new EventSubChannelFollowEvent(data, this._client._config.apiClient)
: new EventSubChannelFollowEvent(data);
}
async _subscribe() {
return this._client._config.managed
? await this._client._config.apiClient.asUser(this._moderatorId, async (ctx) => await ctx.eventSub.subscribeToChannelFollowEvents(this._userId, await this._getTransportOptions()))
: undefined;
}
};
EventSubChannelFollowSubscription = __decorate([
rtfm('eventsub-base', 'EventSubSubscription')
], EventSubChannelFollowSubscription);
export { EventSubChannelFollowSubscription };