Overview
Methods
- applyMiddlewareda
- listena
- resumeExistingSubscriptionsda
- subscribeToChannelBanEventsa
- subscribeToChannelCheerEventsa
- subscribeToChannelFollowEventsa
- subscribeToChannelHypeTrainBeginEventsa
- subscribeToChannelHypeTrainEndEventsa
- subscribeToChannelHypeTrainProgressEventsa
- subscribeToChannelModeratorAddEventsa
- subscribeToChannelModeratorRemoveEventsa
- subscribeToChannelPollBeginEventsa
- subscribeToChannelPollEndEventsa
- subscribeToChannelPollProgressEventsa
- subscribeToChannelPredictionBeginEventsa
- subscribeToChannelPredictionEndEventsa
- subscribeToChannelPredictionLockEventsa
- subscribeToChannelPredictionProgressEventsa
- subscribeToChannelRaidEventsFroma
- subscribeToChannelRaidEventsToa
- subscribeToChannelRedemptionAddEventsa
- subscribeToChannelRedemptionAddEventsForRewarda
- subscribeToChannelRedemptionUpdateEventsa
- subscribeToChannelRedemptionUpdateEventsForRewarda
- subscribeToChannelRewardAddEventsa
- subscribeToChannelRewardRemoveEventsa
- subscribeToChannelRewardRemoveEventsForRewarda
- subscribeToChannelRewardUpdateEventsa
- subscribeToChannelRewardUpdateEventsForRewarda
- subscribeToChannelSubscriptionEndEventsa
- subscribeToChannelSubscriptionEventsa
- subscribeToChannelSubscriptionGiftEventsa
- subscribeToChannelSubscriptionMessageEventsa
- subscribeToChannelUnbanEventsa
- subscribeToChannelUpdateEventsa
- subscribeToExtensionBitsTransactionCreateEventsa
- subscribeToStreamOfflineEventsa
- subscribeToStreamOnlineEventsa
- subscribeToUserAuthorizationRevokeEventsa
- subscribeToUserUpdateEventsa
- unlistena
Constructor
new EventSubListener(apiClient, adapter, secret, config)
Creates a new EventSub listener.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
apiClient | ApiClient | none | The ApiClient instance to use for user info and API requests. | |
adapter | ConnectionAdapter | none | The connection adapter. | |
secret | string | none | The secret for Twitch to sign payloads with. | |
config | EventSubConfig | none | ||
config.logger | Partial<LoggerOptions> | none | Options to pass to the logger. |
Methods
applyMiddleware(app)
asyncUse EventSubMiddleware#applyToApp instead.
Applies middleware that handles EventSub notifications to a connect-compatible app (like express).
The express app should be started before this.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
app | ConnectCompatibleApp | none | The app the middleware should be applied to. |
listen(port)
asyncStarts the backing server and listens to incoming EventSub notifications.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
port | number | none | none |
resumeExistingSubscriptions()
asyncNo replacement; this should only be used with middleware.
Resumes subscriptions that are already registered with Twitch.
subscribeToChannelBanEvents(user, handler)
asyncSubscribes to events that represent a user getting banned from a channel.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The user for which to get notifications for when users get banned in their channel. | |
handler | (event: EventSubChannelBanEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelCheerEvents(user, handler)
asyncSubscribes to events that represent a user cheering some bits.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The user for which to get notifications for about cheers they get. | |
handler | (event: EventSubChannelCheerEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelFollowEvents(user, handler)
asyncSubscribes to events that represent a user following a channel.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The user for which to get notifications about their followers. | |
handler | (event: EventSubChannelFollowEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelHypeTrainBeginEvents(user, handler)
asyncSubscribes to events that represent a Hype Train beginning.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The user for which to get notifications about Hype Trains in their channel. | |
handler | (data: EventSubChannelHypeTrainBeginEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelHypeTrainEndEvents(user, handler)
asyncSubscribes to events that represent the end of a Hype Train in a channel.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The user for which to get notifications about Hype Trains in their channel. | |
handler | (data: EventSubChannelHypeTrainEndEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelHypeTrainProgressEvents(user, handler)
asyncSubscribes to events that represent progress in a Hype Train in a channel.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The user for which to get notifications about Hype Trains in their channel. | |
handler | (data: EventSubChannelHypeTrainProgressEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelModeratorAddEvents(user, handler)
asyncSubscribes to events that represent a user getting moderator permissions in a channel.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The user for which to get notifications for when users get moderator permissions in their channel. | |
handler | (event: EventSubChannelModeratorEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelModeratorRemoveEvents(user, handler)
asyncSubscribes to events that represent a user losing moderator permissions in a channel.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The user for which to get notifications for when users lose moderator permissions in their channel. | |
handler | (event: EventSubChannelModeratorEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelPollBeginEvents(user, handler)
asyncSubscribes to events that represent a poll starting in a channel.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The broadcaster for which to receive poll begin events. | |
handler | (data: EventSubChannelPollBeginEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelPollEndEvents(user, handler)
asyncSubscribes to events that represent a poll ending in a channel.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The broadcaster for which to receive poll end events. | |
handler | (data: EventSubChannelPollEndEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelPollProgressEvents(user, handler)
asyncSubscribes to events that represent a poll being voted on in a channel.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The broadcaster for which to receive poll progress events. | |
handler | (data: EventSubChannelPollProgressEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelPredictionBeginEvents(user, handler)
asyncSubscribes to events that represent a prediction starting in a channel.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The broadcaster for which to receive prediction begin events. | |
handler | (data: EventSubChannelPredictionBeginEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelPredictionEndEvents(user, handler)
asyncSubscribes to events that represent a prediction ending in a channel.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The broadcaster for which to receive prediction end events. | |
handler | (data: EventSubChannelPredictionEndEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelPredictionLockEvents(user, handler)
asyncSubscribes to events that represent a prediction being locked in a channel.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The broadcaster for which to receive prediction lock events. | |
handler | (data: EventSubChannelPredictionLockEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelPredictionProgressEvents(user, handler)
asyncSubscribes to events that represent a prediction being voted on in a channel.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The broadcaster for which to receive prediction progress events. | |
handler | (data: EventSubChannelPredictionProgressEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelRaidEventsFrom(user, handler)
asyncSubscribes to events that represent a broadcaster raiding another broadcaster.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The broadcaster for which to get outgoing raid notifications. | |
handler | (event: EventSubChannelRaidEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelRaidEventsTo(user, handler)
asyncSubscribes to events that represent a broadcaster being raided by another broadcaster.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The broadcaster for which to get incoming raid notifications. | |
handler | (event: EventSubChannelRaidEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelRedemptionAddEvents(user, handler)
asyncSubscribes to events that represents a Channel Points reward being redeemed.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The user for which to get notifications for when their rewards are redeemed. | |
handler | (data: EventSubChannelRedemptionAddEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelRedemptionAddEventsForReward(user, rewardId, handler)
asyncSubscribes to events that represent a specific Channel Points reward being redeemed.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The user for which to get notifications when their reward is redeemed. | |
rewardId | string | none | The ID of the reward for which to get notifications when it is redeemed. | |
handler | (data: EventSubChannelRedemptionAddEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelRedemptionUpdateEvents(user, handler)
asyncSubscribes to events that represent a Channel Points reward being updated by a broadcaster.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The user for which to get notifications for when they update a reward. | |
handler | (data: EventSubChannelRedemptionUpdateEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelRedemptionUpdateEventsForReward(user, rewardId, handler)
asyncSubscribes to events that represent a specific Channel Points reward being updated by a broadcaster.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The user for which to get notifications for when they update the reward. | |
rewardId | string | none | The ID of the reward for which to get notifications when it gets updated. | |
handler | (data: EventSubChannelRedemptionUpdateEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelRewardAddEvents(user, handler)
asyncSubscribes to events that represent a Channel Points reward being added to a channel.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The user for which to get notifications for when they add a reward to their channel. | |
handler | (data: EventSubChannelRewardEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelRewardRemoveEvents(user, handler)
asyncSubscribes to events that represent a Channel Points reward being removed.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The user for which to get notifications for when they remove a reward. | |
handler | (data: EventSubChannelRewardEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelRewardRemoveEventsForReward(user, rewardId, handler)
asyncSubscribes to events that represent a specific Channel Points reward being removed.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The user for which to get notifications for when they remove the reward. | |
rewardId | string | none | The ID of the reward to get notifications for when it is removed. | |
handler | (data: EventSubChannelRewardEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelRewardUpdateEvents(user, handler)
asyncSubscribes to events that represent a Channel Points reward being updated.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The user for which to get notifications for when they update a reward. | |
handler | (data: EventSubChannelRewardEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelRewardUpdateEventsForReward(user, rewardId, handler)
asyncSubscribes to events that represent a specific Channel Points reward being updated.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The user for which to get notifications for when they update the reward. | |
rewardId | string | none | The ID of the reward for which to get notifications when it is updated. | |
handler | (data: EventSubChannelRewardEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelSubscriptionEndEvents(user, handler)
asyncSubscribes to events that represent a user's subscription to a channel ending.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The user for which to get notifications for about ending subscriptions. | |
handler | (event: EventSubChannelSubscriptionEndEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelSubscriptionEvents(user, handler)
asyncSubscribes to events that represent a user subscribing to a channel.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The user for which to get notifications for about their subscribers. | |
handler | (event: EventSubChannelSubscriptionEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelSubscriptionGiftEvents(user, handler)
asyncSubscribes to events that represent a user gifting a subscription to a channel to someone else.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The user for which to get notifications for about subscriptions people gift in their channel. | |
handler | (event: EventSubChannelSubscriptionGiftEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelSubscriptionMessageEvents(user, handler)
asyncSubscribes to events that represent a user's subscription to a channel being announced.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The user for which to get notifications for about announced subscriptions. | |
handler | (event: EventSubChannelSubscriptionMessageEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelUnbanEvents(user, handler)
asyncSubscribes to events that represent a user getting unbanned from a channel.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The user for which to get notifications for when users get unbanned in their channel. | |
handler | (event: EventSubChannelUnbanEvent) => void | none | The function that will be called for any new notifications. |
subscribeToChannelUpdateEvents(user, handler)
asyncSubscribes to events representing a change in channel metadata, e.g. stream title or category.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The user for which to get notifications about updates. | |
handler | (event: EventSubChannelUpdateEvent) => void | none | The function that will be called for any new notifications. |
subscribeToExtensionBitsTransactionCreateEvents(clientId, handler)
asyncSubscribes to events that represent a Bits transaction in an extension.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
clientId | string | none | The Client ID of the extension for which to get notifications for about Bits transactions. | |
handler | (event: EventSubExtensionBitsTransactionCreateEvent) => void | none | The function that will be called for any new notifications. |
subscribeToStreamOfflineEvents(user, handler)
asyncSubscribes to events representing a stream going offline.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The user for which to get notifications about their streams going offline. | |
handler | (event: EventSubStreamOfflineEvent) => void | none | The function that will be called for any new notifications. |
subscribeToStreamOnlineEvents(user, handler)
asyncSubscribes to events representing a stream going live.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The user for which to get notifications about their streams going live. | |
handler | (event: EventSubStreamOnlineEvent) => void | none | The function that will be called for any new notifications. |
subscribeToUserAuthorizationRevokeEvents(clientId, handler)
asyncSubscribes to events that represent a user revoking authorization from an application.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
clientId | string | none | The Client ID for which to get notifications about authorization revocations. | |
handler | (data: EventSubUserAuthorizationRevokeEvent) => void | none | The function that will be called for any new notifications. |
subscribeToUserUpdateEvents(user, handler)
asyncSubscribes to events that represent a user updating their account details.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The user for which to get notifications about account updates. | |
handler | (data: EventSubUserUpdateEvent) => void | none | The function that will be called for any new notifications. |