@twurple/eventsub-base
Version:
Base for the other Twurple EventSub packages
816 lines • 68.4 kB
JavaScript
import { __decorate } from "tslib";
import { createLogger } from '@d-fischer/logger';
import { Enumerable } from '@d-fischer/shared-utils';
import { EventEmitter } from '@d-fischer/typed-event-emitter';
import { extractUserId, } from '@twurple/api';
import { rtfm } from '@twurple/common';
import { EventSubAutoModMessageHoldSubscription } from './subscriptions/EventSubAutoModMessageHoldSubscription.js';
import { EventSubAutoModMessageUpdateSubscription } from './subscriptions/EventSubAutoModMessageUpdateSubscription.js';
import { EventSubAutoModMessageHoldV2Subscription } from './subscriptions/EventSubAutoModMessageHoldV2Subscription.js';
import { EventSubAutoModMessageUpdateV2Subscription } from './subscriptions/EventSubAutoModMessageUpdateV2Subscription.js';
import { EventSubAutoModSettingsUpdateSubscription } from './subscriptions/EventSubAutoModSettingsUpdateSubscription.js';
import { EventSubAutoModTermsUpdateSubscription } from './subscriptions/EventSubAutoModTermsUpdateSubscription.js';
import { EventSubChannelChatUserMessageHoldSubscription } from './subscriptions/EventSubChannelChatUserMessageHoldSubscription.js';
import { EventSubChannelChatUserMessageUpdateSubscription } from './subscriptions/EventSubChannelChatUserMessageUpdateSubscription.js';
import { EventSubChannelAdBreakBeginSubscription } from './subscriptions/EventSubChannelAdBreakBeginSubscription.js';
import { EventSubChannelBanSubscription } from './subscriptions/EventSubChannelBanSubscription.js';
import { EventSubChannelBitsUseSubscription } from './subscriptions/EventSubChannelBitsUseSubscription.js';
import { EventSubChannelCharityCampaignProgressSubscription } from './subscriptions/EventSubChannelCharityCampaignProgressSubscription.js';
import { EventSubChannelCharityCampaignStartSubscription } from './subscriptions/EventSubChannelCharityCampaignStartSubscription.js';
import { EventSubChannelCharityCampaignStopSubscription } from './subscriptions/EventSubChannelCharityCampaignStopSubscription.js';
import { EventSubChannelCharityDonationSubscription } from './subscriptions/EventSubChannelCharityDonationSubscription.js';
import { EventSubChannelChatClearSubscription } from './subscriptions/EventSubChannelChatClearSubscription.js';
import { EventSubChannelChatClearUserMessagesSubscription } from './subscriptions/EventSubChannelChatClearUserMessagesSubscription.js';
import { EventSubChannelChatMessageDeleteSubscription } from './subscriptions/EventSubChannelChatMessageDeleteSubscription.js';
import { EventSubChannelChatMessageSubscription } from './subscriptions/EventSubChannelChatMessageSubscription.js';
import { EventSubChannelChatNotificationSubscription } from './subscriptions/EventSubChannelChatNotificationSubscription.js';
import { EventSubChannelChatSettingsUpdateSubscription } from './subscriptions/EventSubChannelChatSettingsUpdateSubscription.js';
import { EventSubChannelCheerSubscription } from './subscriptions/EventSubChannelCheerSubscription.js';
import { EventSubChannelFollowSubscription } from './subscriptions/EventSubChannelFollowSubscription.js';
import { EventSubChannelGoalBeginSubscription } from './subscriptions/EventSubChannelGoalBeginSubscription.js';
import { EventSubChannelGoalEndSubscription } from './subscriptions/EventSubChannelGoalEndSubscription.js';
import { EventSubChannelGoalProgressSubscription } from './subscriptions/EventSubChannelGoalProgressSubscription.js';
import { EventSubChannelHypeTrainBeginSubscription } from './subscriptions/EventSubChannelHypeTrainBeginSubscription.js';
import { EventSubChannelHypeTrainEndSubscription } from './subscriptions/EventSubChannelHypeTrainEndSubscription.js';
import { EventSubChannelHypeTrainProgressSubscription } from './subscriptions/EventSubChannelHypeTrainProgressSubscription.js';
import { EventSubChannelHypeTrainBeginV2Subscription } from './subscriptions/EventSubChannelHypeTrainBeginV2Subscription.js';
import { EventSubChannelHypeTrainProgressV2Subscription } from './subscriptions/EventSubChannelHypeTrainProgressV2Subscription.js';
import { EventSubChannelHypeTrainEndV2Subscription } from './subscriptions/EventSubChannelHypeTrainEndV2Subscription.js';
import { EventSubChannelModerateSubscription } from './subscriptions/EventSubChannelModerateSubscription.js';
import { EventSubChannelModeratorAddSubscription } from './subscriptions/EventSubChannelModeratorAddSubscription.js';
import { EventSubChannelModeratorRemoveSubscription } from './subscriptions/EventSubChannelModeratorRemoveSubscription.js';
import { EventSubChannelPollBeginSubscription } from './subscriptions/EventSubChannelPollBeginSubscription.js';
import { EventSubChannelPollEndSubscription } from './subscriptions/EventSubChannelPollEndSubscription.js';
import { EventSubChannelPollProgressSubscription } from './subscriptions/EventSubChannelPollProgressSubscription.js';
import { EventSubChannelPredictionBeginSubscription } from './subscriptions/EventSubChannelPredictionBeginSubscription.js';
import { EventSubChannelPredictionEndSubscription } from './subscriptions/EventSubChannelPredictionEndSubscription.js';
import { EventSubChannelPredictionLockSubscription } from './subscriptions/EventSubChannelPredictionLockSubscription.js';
import { EventSubChannelPredictionProgressSubscription } from './subscriptions/EventSubChannelPredictionProgressSubscription.js';
import { EventSubChannelRaidSubscription } from './subscriptions/EventSubChannelRaidSubscription.js';
import { EventSubChannelRedemptionAddSubscription } from './subscriptions/EventSubChannelRedemptionAddSubscription.js';
import { EventSubChannelRedemptionUpdateSubscription } from './subscriptions/EventSubChannelRedemptionUpdateSubscription.js';
import { EventSubChannelRewardAddSubscription } from './subscriptions/EventSubChannelRewardAddSubscription.js';
import { EventSubChannelRewardRemoveSubscription } from './subscriptions/EventSubChannelRewardRemoveSubscription.js';
import { EventSubChannelRewardUpdateSubscription } from './subscriptions/EventSubChannelRewardUpdateSubscription.js';
import { EventSubChannelAutomaticRewardRedemptionAddSubscription } from './subscriptions/EventSubChannelAutomaticRewardRedemptionAddSubscription.js';
import { EventSubChannelAutomaticRewardRedemptionAddV2Subscription } from './subscriptions/EventSubChannelAutomaticRewardRedemptionAddV2Subscription.js';
import { EventSubChannelSharedChatSessionBeginSubscription } from './subscriptions/EventSubChannelSharedChatSessionBeginSubscription.js';
import { EventSubChannelSharedChatSessionUpdateSubscription } from './subscriptions/EventSubChannelSharedChatSessionUpdateSubscription.js';
import { EventSubChannelSharedChatSessionEndSubscription } from './subscriptions/EventSubChannelSharedChatSessionEndSubscription.js';
import { EventSubChannelShieldModeBeginSubscription } from './subscriptions/EventSubChannelShieldModeBeginSubscription.js';
import { EventSubChannelShieldModeEndSubscription } from './subscriptions/EventSubChannelShieldModeEndSubscription.js';
import { EventSubChannelShoutoutCreateSubscription } from './subscriptions/EventSubChannelShoutoutCreateSubscription.js';
import { EventSubChannelShoutoutReceiveSubscription } from './subscriptions/EventSubChannelShoutoutReceiveSubscription.js';
import { EventSubChannelSubscriptionEndSubscription } from './subscriptions/EventSubChannelSubscriptionEndSubscription.js';
import { EventSubChannelSubscriptionGiftSubscription } from './subscriptions/EventSubChannelSubscriptionGiftSubscription.js';
import { EventSubChannelSubscriptionMessageSubscription } from './subscriptions/EventSubChannelSubscriptionMessageSubscription.js';
import { EventSubChannelSubscriptionSubscription } from './subscriptions/EventSubChannelSubscriptionSubscription.js';
import { EventSubChannelSuspiciousUserUpdateSubscription } from './subscriptions/EventSubChannelSuspiciousUserUpdateSubscription.js';
import { EventSubChannelSuspiciousUserMessageSubscription } from './subscriptions/EventSubChannelSuspiciousUserMessageSubscription.js';
import { EventSubChannelUnbanRequestCreateSubscription } from './subscriptions/EventSubChannelUnbanRequestCreateSubscription.js';
import { EventSubChannelUnbanRequestResolveSubscription } from './subscriptions/EventSubChannelUnbanRequestResolveSubscription.js';
import { EventSubChannelUnbanSubscription } from './subscriptions/EventSubChannelUnbanSubscription.js';
import { EventSubChannelUpdateSubscription } from './subscriptions/EventSubChannelUpdateSubscription.js';
import { EventSubChannelVipAddSubscription } from './subscriptions/EventSubChannelVipAddSubscription.js';
import { EventSubChannelVipRemoveSubscription } from './subscriptions/EventSubChannelVipRemoveSubscription.js';
import { EventSubChannelWarningAcknowledgeSubscription } from './subscriptions/EventSubChannelWarningAcknowledgeSubscription.js';
import { EventSubChannelWarningSendSubscription } from './subscriptions/EventSubChannelWarningSendSubscription.js';
import { EventSubDropEntitlementGrantSubscription } from './subscriptions/EventSubDropEntitlementGrantSubscription.js';
import { EventSubExtensionBitsTransactionCreateSubscription } from './subscriptions/EventSubExtensionBitsTransactionCreateSubscription.js';
import { EventSubStreamOfflineSubscription } from './subscriptions/EventSubStreamOfflineSubscription.js';
import { EventSubStreamOnlineSubscription } from './subscriptions/EventSubStreamOnlineSubscription.js';
import { EventSubUserAuthorizationGrantSubscription } from './subscriptions/EventSubUserAuthorizationGrantSubscription.js';
import { EventSubUserAuthorizationRevokeSubscription } from './subscriptions/EventSubUserAuthorizationRevokeSubscription.js';
import { EventSubUserUpdateSubscription } from './subscriptions/EventSubUserUpdateSubscription.js';
import { EventSubUserWhisperMessageSubscription } from './subscriptions/EventSubUserWhisperMessageSubscription.js';
const numberRegex = /^\d+$/;
/**
* @private
* @hideProtected
*/
let EventSubBase = class EventSubBase extends EventEmitter {
_subscriptions = new Map();
_subscriptionsByTwitchId = new Map();
_twitchSubscriptions = new Map();
_seenEventIds = new Set();
/** @private */ _apiClient;
/** @private */ _logger;
/**
* Fires when a subscription is revoked.
*
* @eventListener
*
* @param subscription The subscription that was revoked.
*/
onRevoke = this.registerEvent();
/**
* Fires when the client successfully created a subscription.
*
* @eventListener
*
* @param subscription The subscription that was successfully created.
* @param apiSubscription The subscription data from the API.
*/
onSubscriptionCreateSuccess = this.registerEvent();
/**
* Fires when the client fails to create a subscription.
*
* @eventListener
*
* @param subscription The subscription that was not successfully created.
* @param error The error that was thrown.
*/
onSubscriptionCreateFailure = this.registerEvent();
/**
* Fires when the client successfully deleted a subscription.
*
* @eventListener
*
* @param subscription The subscription that was successfully deleted.
*/
onSubscriptionDeleteSuccess = this.registerEvent();
/**
* Fires when the client fails to delete a subscription.
*
* @eventListener
*
* @param subscription The subscription that was not successfully deleted.
* @param error The error that was thrown.
*/
onSubscriptionDeleteFailure = this.registerEvent();
constructor(config) {
super();
this._apiClient = config.apiClient;
this._logger = createLogger({
name: 'twurple:eventsub',
...config.logger,
});
}
/** @private */
_dropSubscription(id) {
this._subscriptions.delete(id);
}
/** @private */
_dropTwitchSubscription(id) {
if (this._twitchSubscriptions.has(id)) {
const data = this._twitchSubscriptions.get(id);
this._twitchSubscriptions.delete(id);
this._subscriptionsByTwitchId.delete(data.id);
}
}
/** @private */
_registerTwitchSubscription(subscription, data) {
this._twitchSubscriptions.set(subscription.id, data);
this._subscriptionsByTwitchId.set(data.id, subscription);
this.emit(this.onSubscriptionCreateSuccess, subscription, data);
}
/** @private */
_notifySubscriptionCreateError(subscription, error) {
this.emit(this.onSubscriptionCreateFailure, subscription, error);
}
/** @private */
_notifySubscriptionDeleteSuccess(subscription) {
this.emit(this.onSubscriptionDeleteSuccess, subscription);
}
/** @private */
_notifySubscriptionDeleteError(subscription, error) {
this.emit(this.onSubscriptionDeleteFailure, subscription, error);
}
/**
* Subscribes to events representing a stream going live.
*
* @param user The user for which to get notifications about their streams going live.
* @param handler The function that will be called for any new notifications.
*/
onStreamOnline(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToStreamOnlineEvents');
return this._genericSubscribe(EventSubStreamOnlineSubscription, handler, this, userId);
}
/**
* Subscribes to events representing a stream going offline.
*
* @param user The user for which to get notifications about their streams going offline.
* @param handler The function that will be called for any new notifications.
*/
onStreamOffline(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToStreamOfflineEvents');
return this._genericSubscribe(EventSubStreamOfflineSubscription, handler, this, userId);
}
/**
* Subscribes to events representing a change in channel metadata, e.g. stream title or category.
*
* @param user The user for which to get notifications about updates.
* @param handler The function that will be called for any new notifications.
*/
onChannelUpdate(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelUpdateEvents');
return this._genericSubscribe(EventSubChannelUpdateSubscription, handler, this, userId);
}
/**
* Subscribes to events that represent a user following a channel.
*
* @param user The user for which to get notifications about their followers.
* @param moderator A user that has permission to read followers in the broadcaster's channel.
* @param handler The function that will be called for any new notifications.
*/
onChannelFollow(user, moderator, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelFollowEvents');
const moderatorId = this._extractUserIdWithNumericWarning(moderator, 'subscribeToChannelFollowEvents');
return this._genericSubscribe(EventSubChannelFollowSubscription, handler, this, userId, moderatorId);
}
/**
* Subscribes to events that represent a user subscribing to a channel.
*
* @param user The user for which to get notifications for about their subscribers.
* @param handler The function that will be called for any new notifications.
*/
onChannelSubscription(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelSubscriptionEvents');
return this._genericSubscribe(EventSubChannelSubscriptionSubscription, handler, this, userId);
}
/**
* Subscribes to events that represent a user gifting a subscription to a channel to someone else.
*
* @param user The user for which to get notifications for about subscriptions people gift in their channel.
* @param handler The function that will be called for any new notifications.
*/
onChannelSubscriptionGift(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelSubscriptionGiftEvents');
return this._genericSubscribe(EventSubChannelSubscriptionGiftSubscription, handler, this, userId);
}
/**
* Subscribes to events that represent a user's subscription to a channel being announced.
*
* @param user The user for which to get notifications for about announced subscriptions.
* @param handler The function that will be called for any new notifications.
*/
onChannelSubscriptionMessage(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelSubscriptionMessageEvents');
return this._genericSubscribe(EventSubChannelSubscriptionMessageSubscription, handler, this, userId);
}
/**
* Subscribes to events that represent a user's subscription to a channel ending.
*
* @param user The user for which to get notifications for about ending subscriptions.
* @param handler The function that will be called for any new notifications.
*/
onChannelSubscriptionEnd(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelSubscriptionEndEvents');
return this._genericSubscribe(EventSubChannelSubscriptionEndSubscription, handler, this, userId);
}
/**
* Subscribes to events that represent a user cheering some bits.
*
* @param user The user for which to get notifications for about cheers they get.
* @param handler The function that will be called for any new notifications.
*/
onChannelCheer(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelCheerEvents');
return this._genericSubscribe(EventSubChannelCheerSubscription, handler, this, userId);
}
/**
* Subscribes to events that represent a charity campaign starting in a channel.
*
* @param user The user for which to get notifications about charity campaigns starting.
* @param handler The function that will be called for any new notifications.
*/
onChannelCharityCampaignStart(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelCharityCampaignStartEvents');
return this._genericSubscribe(EventSubChannelCharityCampaignStartSubscription, handler, this, userId);
}
/**
* Subscribes to events that represent a charity campaign ending in a channel.
*
* @param user The user for which to get notifications about charity campaigns ending.
* @param handler The function that will be called for any new notifications.
*/
onChannelCharityCampaignStop(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelCharityCampaignStopEvents');
return this._genericSubscribe(EventSubChannelCharityCampaignStopSubscription, handler, this, userId);
}
/**
* Subscribes to events that represent a donation to a charity campaign in a channel.
*
* @param user The user for which to get notifications about charity campaign donations.
* @param handler The function that will be called for any new notifications.
*/
onChannelCharityDonation(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelCharityDonationEvents');
return this._genericSubscribe(EventSubChannelCharityDonationSubscription, handler, this, userId);
}
/**
* Subscribes to events that represent progress in a charity campaign in a channel.
*
* @param user The user for which to get notifications about charity campaign progress.
* @param handler The function that will be called for any new notifications.
*/
onChannelCharityCampaignProgress(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelCharityCampaignProgressEvents');
return this._genericSubscribe(EventSubChannelCharityCampaignProgressSubscription, handler, this, userId);
}
/**
* Subscribes to events that represent a user getting banned from a channel.
*
* @param user The user for which to get notifications for when users get banned in their channel.
* @param handler The function that will be called for any new notifications.
*/
onChannelBan(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelBanEvents');
return this._genericSubscribe(EventSubChannelBanSubscription, handler, this, userId);
}
/**
* Subscribes to events that represent a user getting unbanned from a channel.
*
* @param user The user for which to get notifications for when users get unbanned in their channel.
* @param handler The function that will be called for any new notifications.
*/
onChannelUnban(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelUnbanEvents');
return this._genericSubscribe(EventSubChannelUnbanSubscription, handler, this, userId);
}
/**
* Subscribes to events that represent Shield Mode being activated in a channel.
*
* @param broadcaster The user for which to get notifications for when Shield Mode is activated in their channel.
* @param moderator A user that has permission to read Shield Mode status in the broadcaster's channel.
* @param handler The function that will be called for any new notifications.
*/
onChannelShieldModeBegin(broadcaster, moderator, handler) {
const broadcasterId = this._extractUserIdWithNumericWarning(broadcaster, 'subscribeToChannelShieldModeStartEvents');
const moderatorId = this._extractUserIdWithNumericWarning(moderator, 'subscribeToChannelShieldModeStartEvents');
return this._genericSubscribe(EventSubChannelShieldModeBeginSubscription, handler, this, broadcasterId, moderatorId);
}
/**
* Subscribes to events that represent Shield Mode being deactivated in a channel.
*
* @param broadcaster The user for which to get notifications for when Shield Mode is deactivated in their channel.
* @param moderator A user that has permission to read Shield Mode status in the broadcaster's channel.
* @param handler The function that will be called for any new notifications.
*/
onChannelShieldModeEnd(broadcaster, moderator, handler) {
const broadcasterId = this._extractUserIdWithNumericWarning(broadcaster, 'subscribeToChannelShieldModeEndEvents');
const moderatorId = this._extractUserIdWithNumericWarning(moderator, 'subscribeToChannelShieldModeEndEvents');
return this._genericSubscribe(EventSubChannelShieldModeEndSubscription, handler, this, broadcasterId, moderatorId);
}
/**
* Subscribes to events that represent a moderator performing an action on a channel.
*
* This requires the following scopes:
* - `moderator:read:blocked_terms` OR `moderator:manage:blocked_terms`
* - `moderator:read:chat_settings` OR `moderator:manage:chat_settings`
* - `moderator:read:unban_requests` OR `moderator:manage:unban_requests`
* - `moderator:read:banned_users` OR `moderator:manage:banned_users`
* - `moderator:read:chat_messages` OR `moderator:manage:chat_messages`
* - `moderator:read:moderators`
* - `moderator:read:vips`
*
* These scope requirements cannot be checked by the library, so they are just assumed.
* Make sure to catch authorization errors yourself.
*
* @param broadcaster The user for which to get notifications about moderation actions on their channel.
* @param moderator The user that has moderator permission on the broadcaster's channel.
* @param handler The function that will be called for any new notifications.
*/
onChannelModerate(broadcaster, moderator, handler) {
const broadcasterId = this._extractUserIdWithNumericWarning(broadcaster, 'onChannelModerate');
const moderatorId = this._extractUserIdWithNumericWarning(moderator, 'onChannelModerate');
return this._genericSubscribe(EventSubChannelModerateSubscription, handler, this, broadcasterId, moderatorId);
}
/**
* Subscribes to events that represent a user getting moderator permissions in a channel.
*
* @param user The user for which to get notifications for when users get moderator permissions in their channel.
* @param handler The function that will be called for any new notifications.
*/
onChannelModeratorAdd(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelModeratorAddEvents');
return this._genericSubscribe(EventSubChannelModeratorAddSubscription, handler, this, userId);
}
/**
* Subscribes to events that represent a user losing moderator permissions in a channel.
*
* @param user The user for which to get notifications for when users lose moderator permissions in their channel.
* @param handler The function that will be called for any new notifications.
*/
onChannelModeratorRemove(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelModeratorRemoveEvents');
return this._genericSubscribe(EventSubChannelModeratorRemoveSubscription, handler, this, userId);
}
/**
* Subscribes to events that represent a broadcaster raiding another broadcaster.
*
* @param user The broadcaster for which to get outgoing raid notifications.
* @param handler The function that will be called for any new notifications.
*/
onChannelRaidFrom(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelRaidEventsFrom');
return this._genericSubscribe(EventSubChannelRaidSubscription, handler, this, userId, 'from');
}
/**
* Subscribes to events that represent a broadcaster being raided by another broadcaster.
*
* @param user The broadcaster for which to get incoming raid notifications.
* @param handler The function that will be called for any new notifications.
*/
onChannelRaidTo(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelRaidEventsTo');
return this._genericSubscribe(EventSubChannelRaidSubscription, handler, this, userId, 'to');
}
/**
* Subscribes to events that represent a Channel Points reward being added to a channel.
*
* @param user The user for which to get notifications for when they add a reward to their channel.
* @param handler The function that will be called for any new notifications.
*/
onChannelRewardAdd(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelRewardAddEvents');
return this._genericSubscribe(EventSubChannelRewardAddSubscription, handler, this, userId);
}
/**
* Subscribes to events that represent a Channel Points reward being updated.
*
* @param user The user for which to get notifications for when they update a reward.
* @param handler The function that will be called for any new notifications.
*/
onChannelRewardUpdate(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToRewardUpdateEvents');
return this._genericSubscribe(EventSubChannelRewardUpdateSubscription, handler, this, userId);
}
/**
* Subscribes to events that represent a specific Channel Points reward being updated.
*
* @param user The user for which to get notifications for when they update the reward.
* @param rewardId The ID of the reward for which to get notifications when it is updated.
* @param handler The function that will be called for any new notifications.
*/
onChannelRewardUpdateForReward(user, rewardId, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToRewardUpdateEvents');
return this._genericSubscribe(EventSubChannelRewardUpdateSubscription, handler, this, userId, rewardId);
}
/**
* Subscribes to events that represent a Channel Points reward being removed.
*
* @param user The user for which to get notifications for when they remove a reward.
* @param handler The function that will be called for any new notifications.
*/
onChannelRewardRemove(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToRewardRemoveEvents');
return this._genericSubscribe(EventSubChannelRewardRemoveSubscription, handler, this, userId);
}
/**
* Subscribes to events that represent a specific Channel Points reward being removed.
*
* @param user The user for which to get notifications for when they remove the reward.
* @param rewardId The ID of the reward to get notifications for when it is removed.
* @param handler The function that will be called for any new notifications.
*/
onChannelRewardRemoveForReward(user, rewardId, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToRewardRemoveEventsForReward');
return this._genericSubscribe(EventSubChannelRewardRemoveSubscription, handler, this, userId, rewardId);
}
/**
* Subscribes to events that represents a Channel Points reward being redeemed.
*
* @param user The user for which to get notifications for when their rewards are redeemed.
* @param handler The function that will be called for any new notifications.
*/
onChannelRedemptionAdd(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelRedemptionEvents');
return this._genericSubscribe(EventSubChannelRedemptionAddSubscription, handler, this, userId);
}
/**
* Subscribes to events that represent a specific Channel Points reward being redeemed.
*
* @param user The user for which to get notifications when their reward is redeemed.
* @param rewardId The ID of the reward for which to get notifications when it is redeemed.
* @param handler The function that will be called for any new notifications.
*/
onChannelRedemptionAddForReward(user, rewardId, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToRedemptionAddEventsForReward');
return this._genericSubscribe(EventSubChannelRedemptionAddSubscription, handler, this, userId, rewardId);
}
/**
* Subscribes to events that represent a Channel Points reward being updated by a broadcaster.
*
* @param user The user for which to get notifications for when they update a reward.
* @param handler The function that will be called for any new notifications.
*/
onChannelRedemptionUpdate(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelRedemptionUpdateEvents');
return this._genericSubscribe(EventSubChannelRedemptionUpdateSubscription, handler, this, userId);
}
/**
* Subscribes to events that represent a specific Channel Points reward being updated by a broadcaster.
*
* @param user The user for which to get notifications for when they update the reward.
* @param rewardId The ID of the reward for which to get notifications when it gets updated.
* @param handler The function that will be called for any new notifications.
*/
onChannelRedemptionUpdateForReward(user, rewardId, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelRedemptionUpdateEventsForReward');
return this._genericSubscribe(EventSubChannelRedemptionUpdateSubscription, handler, this, userId, rewardId);
}
/**
* Subscribes to events that represent a specific Channel Points automatic reward being redeemed.
*
* @param user The user for which to get notifications when their automatic reward is redeemed.
* @param handler The function that will be called for any new notifications.
*/
onChannelAutomaticRewardRedemptionAdd(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'onChannelAutomaticRewardRedemptionAdd');
return this._genericSubscribe(EventSubChannelAutomaticRewardRedemptionAddSubscription, handler, this, userId);
}
/**
* Subscribes to events that represent a specific Channel Points automatic reward being redeemed.
*
* @param user The user for which to get notifications when their automatic reward is redeemed.
* @param handler The function that will be called for any new notifications.
*/
onChannelAutomaticRewardRedemptionAddV2(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'onChannelAutomaticRewardRedemptionAddV2');
return this._genericSubscribe(EventSubChannelAutomaticRewardRedemptionAddV2Subscription, handler, this, userId);
}
/**
* Subscribes to events that represent a poll starting in a channel.
*
* @param user The broadcaster for which to receive poll begin events.
* @param handler The function that will be called for any new notifications.
*/
onChannelPollBegin(user, handler) {
const broadcasterId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelPollBeginEvents');
return this._genericSubscribe(EventSubChannelPollBeginSubscription, handler, this, broadcasterId);
}
/**
* Subscribes to events that represent a poll being voted on in a channel.
*
* @param user The broadcaster for which to receive poll progress events.
* @param handler The function that will be called for any new notifications.
*/
onChannelPollProgress(user, handler) {
const broadcasterId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelPollProgressEvents');
return this._genericSubscribe(EventSubChannelPollProgressSubscription, handler, this, broadcasterId);
}
/**
* Subscribes to events that represent a poll ending in a channel.
*
* @param user The broadcaster for which to receive poll end events.
* @param handler The function that will be called for any new notifications.
*/
onChannelPollEnd(user, handler) {
const broadcasterId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelPollEndEvents');
return this._genericSubscribe(EventSubChannelPollEndSubscription, handler, this, broadcasterId);
}
/**
* Subscribes to events that represent a prediction starting in a channel.
*
* @param user The broadcaster for which to receive prediction begin events.
* @param handler The function that will be called for any new notifications.
*/
onChannelPredictionBegin(user, handler) {
const broadcasterId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelPredictionBeginEvents');
return this._genericSubscribe(EventSubChannelPredictionBeginSubscription, handler, this, broadcasterId);
}
/**
* Subscribes to events that represent a prediction being voted on in a channel.
*
* @param user The broadcaster for which to receive prediction progress events.
* @param handler The function that will be called for any new notifications.
*/
onChannelPredictionProgress(user, handler) {
const broadcasterId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelPredictionProgressEvents');
return this._genericSubscribe(EventSubChannelPredictionProgressSubscription, handler, this, broadcasterId);
}
/**
* Subscribes to events that represent a prediction being locked in a channel.
*
* @param user The broadcaster for which to receive prediction lock events.
* @param handler The function that will be called for any new notifications.
*/
onChannelPredictionLock(user, handler) {
const broadcasterId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelPredictionLockEvents');
return this._genericSubscribe(EventSubChannelPredictionLockSubscription, handler, this, broadcasterId);
}
/**
* Subscribes to events that represent a prediction ending in a channel.
*
* @param user The broadcaster for which to receive prediction end events.
* @param handler The function that will be called for any new notifications.
*/
onChannelPredictionEnd(user, handler) {
const broadcasterId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelPredictionEndEvents');
return this._genericSubscribe(EventSubChannelPredictionEndSubscription, handler, this, broadcasterId);
}
/**
* Subscribes to events that represent a Goal beginning.
*
* @param user The user for which to get notifications about Goals in their channel.
* @param handler The function that will be called for any new notifications.
*/
onChannelGoalBegin(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelGoalBeginEvents');
return this._genericSubscribe(EventSubChannelGoalBeginSubscription, handler, this, userId);
}
/**
* Subscribes to events that represent progress in a Goal in a channel.
*
* @param user The user for which to get notifications about Goals in their channel.
* @param handler The function that will be called for any new notifications.
*/
onChannelGoalProgress(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelGoalProgressEvents');
return this._genericSubscribe(EventSubChannelGoalProgressSubscription, handler, this, userId);
}
/**
* Subscribes to events that represent the end of a Goal in a channel.
*
* @param user The user for which to get notifications about Goals in their channel.
* @param handler The function that will be called for any new notifications.
*/
onChannelGoalEnd(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelGoalEndEvents');
return this._genericSubscribe(EventSubChannelGoalEndSubscription, handler, this, userId);
}
/**
* Subscribes to events that represent a Hype Train beginning.
*
* @param user The user for which to get notifications about Hype Trains in their channel.
* @param handler The function that will be called for any new notifications.
*/
onChannelHypeTrainBegin(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelHypeTrainBeginEvents');
return this._genericSubscribe(EventSubChannelHypeTrainBeginSubscription, handler, this, userId);
}
/**
* Subscribes to events that represent progress in a Hype Train in a channel.
*
* @param user The user for which to get notifications about Hype Trains in their channel.
* @param handler The function that will be called for any new notifications.
*/
onChannelHypeTrainProgress(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelHypeTrainProgressEvents');
return this._genericSubscribe(EventSubChannelHypeTrainProgressSubscription, handler, this, userId);
}
/**
* Subscribes to events that represent the end of a Hype Train in a channel.
*
* @param user The user for which to get notifications about Hype Trains in their channel.
* @param handler The function that will be called for any new notifications.
*/
onChannelHypeTrainEnd(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelHypeTrainEndEvents');
return this._genericSubscribe(EventSubChannelHypeTrainEndSubscription, handler, this, userId);
}
/**
* Subscribes to events that represent a Hype Train beginning.
*
* @param user The user for which to get notifications about Hype Trains in their channel.
* @param handler The function that will be called for any new notifications.
*/
onChannelHypeTrainBeginV2(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'onChannelHypeTrainBeginV2');
return this._genericSubscribe(EventSubChannelHypeTrainBeginV2Subscription, handler, this, userId);
}
/**
* Subscribes to events that represent progress in a Hype Train in a channel.
*
* @param user The user for which to get notifications about Hype Trains in their channel.
* @param handler The function that will be called for any new notifications.
*/
onChannelHypeTrainProgressV2(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'onChannelHypeTrainProgressV2');
return this._genericSubscribe(EventSubChannelHypeTrainProgressV2Subscription, handler, this, userId);
}
/**
* Subscribes to events that represent the end of a Hype Train in a channel.
*
* @param user The user for which to get notifications about Hype Trains in their channel.
* @param handler The function that will be called for any new notifications.
*/
onChannelHypeTrainEndV2(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'onChannelHypeTrainEndV2');
return this._genericSubscribe(EventSubChannelHypeTrainEndV2Subscription, handler, this, userId);
}
/**
* Subscribes to events that represent a broadcaster shouting out another broadcaster.
*
* @param broadcaster The broadcaster for which you want to listen to outgoing shoutout events.
* @param moderator A user that has permission to see or manage shoutout events in the broadcaster's channel.
* @param handler The function that will be called for any new notifications.
*/
onChannelShoutoutCreate(broadcaster, moderator, handler) {
const broadcasterId = this._extractUserIdWithNumericWarning(broadcaster, 'subscribeToChannelShoutoutCreateEvents');
const moderatorId = this._extractUserIdWithNumericWarning(moderator, 'subscribeToChannelShoutoutCreateEvents');
return this._genericSubscribe(EventSubChannelShoutoutCreateSubscription, handler, this, broadcasterId, moderatorId);
}
/**
* Subscribes to events that represent a broadcaster being shouted out by another broadcaster.
*
* @param broadcaster The broadcaster for which you want to listen to incoming shoutout events.
* @param moderator A user that has permission to see or manage shoutout events in the broadcaster's channel.
* @param handler The function that will be called for any new notifications.
*/
onChannelShoutoutReceive(broadcaster, moderator, handler) {
const broadcasterId = this._extractUserIdWithNumericWarning(broadcaster, 'subscribeToChannelShoutoutReceiveEvents');
const moderatorId = this._extractUserIdWithNumericWarning(moderator, 'subscribeToChannelShoutoutReceiveEvents');
return this._genericSubscribe(EventSubChannelShoutoutReceiveSubscription, handler, this, broadcasterId, moderatorId);
}
/**
* Subscribes to events that represent an ad break beginning.
*
* @param user The user for which to get notifications about ad breaks in their channel.
* @param handler The function that will be called for any new notifications.
*/
onChannelAdBreakBegin(user, handler) {
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelAdBreakBeginEvents');
return this._genericSubscribe(EventSubChannelAdBreakBeginSubscription, handler, this, userId);
}
/**
* Subscribes to events that represent an channel's chat being cleared.
*
* @param broadcaster The user for which to get notifications about chat being cleared in their channel.
* @param user The user to use for reading the channel's chat.
* @param handler The function that will be called for any new notifications.
*/
onChannelChatClear(broadcaster, user, handler) {
const broadcasterId = this._extractUserIdWithNumericWarning(broadcaster, 'subscribeToChannelChatClearEvents');
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelChatClearEvents');
return this._genericSubscribe(EventSubChannelChatClearSubscription, handler, this, broadcasterId, userId);
}
/**
* Subscribes to events that represent a user's chat messages being cleared in a channel.
*
* @param broadcaster The user for which to get notifications about a user's chat messages being cleared in their channel.
* @param user The user to use for reading the channel's chat.
* @param handler The function that will be called for any new notifications.
*/
onChannelChatClearUserMessages(broadcaster, user, handler) {
const broadcasterId = this._extractUserIdWithNumericWarning(broadcaster, 'subscribeToChannelChatClearUserMessagesEvents');
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelChatClearUserMessagesEvents');
return this._genericSubscribe(EventSubChannelChatClearUserMessagesSubscription, handler, this, broadcasterId, userId);
}
/**
* Subscribes to events that represent a chat message being deleted in a channel.
*
* @param broadcaster The user for which to get notifications about a chat message being deleted in their channel.
* @param user The user to use for reading the channel's chat.
* @param handler The function that will be called for any new notifications.
*/
onChannelChatMessageDelete(broadcaster, user, handler) {
const broadcasterId = this._extractUserIdWithNumericWarning(broadcaster, 'subscribeToChannelChatMessageDeleteEvents');
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelChatMessageDeleteEvents');
return this._genericSubscribe(EventSubChannelChatMessageDeleteSubscription, handler, this, broadcasterId, userId);
}
/**
* Subscribes to events that represent a chat notification being sent to a channel.
*
* @param broadcaster The user for which to get chat notifications in their channel.
* @param user The user to use for reading the channel's chat.
* @param handler The function that will be called for any new notifications.
*/
onChannelChatNotification(broadcaster, user, handler) {
const broadcasterId = this._extractUserIdWithNumericWarning(broadcaster, 'subscribeToChannelChatNotificationEvents');
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelChatNotificationEvents');
return this._genericSubscribe(EventSubChannelChatNotificationSubscription, handler, this, broadcasterId, userId);
}
/**
* Subscribes to events that represent a chat message being sent to a channel.
*
* @param broadcaster The user for which to get chat message notifications in their channel.
* @param user The user to use for reading the channel's chat.
* @param handler The function that will be called for any new notifications.
*/
onChannelChatMessage(broadcaster, user, handler) {
const broadcasterId = this._extractUserIdWithNumericWarning(broadcaster, 'subscribeToChannelChatMessageDeleteEvents');
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelChatMessageEvents');
return this._genericSubscribe(EventSubChannelChatMessageSubscription, handler, this, broadcasterId, userId);
}
/**
* Subscribes to events that represent chat settings being updated in a channel.
*
* @param broadcaster The user for which to get notifications about chat settings being updated in their channel.
* @param user The user to use for reading the channel's chat.
* @param handler The function that will be called for any new notifications.
*/
onChannelChatSettingsUpdate(broadcaster, user, handler) {
const broadcasterId = this._extractUserIdWithNumericWarning(broadcaster, 'subscribeToChannelChatSettingsUpdateEvents');
const userId = this._extractUserIdWithNumericWarning(user, 'subscribeToChannelChatSettingsUpdateEvents');
return this._genericSubscribe(EventSubChannelChatSettingsUpdateSubscription, handler, this, broadcasterId, userId);
}
/**
* Subscribes to events that represent an unban request being created.
*
* @param broadcaster The user for which to get notifications about unban requests being created in their channel.
* @param moderator A user that has permission to read unban requests in the broadcaster's channel.
* @param handler The function that will be called for any new notifications.
*/
onChannelUnbanRequestCreate(broadcaster, moderator, handler) {
const broadcasterId = this._extractUserIdWithNumericWarning(broadcaster, 'subscribeToChannelUnbanRequestCreateEvents');
const moderatorId = this._extractUserIdWithNumericWarning(moderator, 'subscribeToChannelUnbanRequestCreateEvents');
return this._genericSubscribe(EventSubChannelUnbanRequestCreateSubscription, handler, this, broadcasterId, moderatorId);
}
/**
* Subscribes to events that represent an unban request being resolved.
*
* @param broadcaster The user for which to get notifications about unban requests being resolved in their channel.
* @param moderator A user that has permission to read unban requests in the broadcaster's channel.
* @param handler The function