Overview
Methods
- applyMiddlewarea
- listena
- resumeExistingSubscriptionsa
- subscribeToChannelBanEventsa
- subscribeToChannelCheerEventsa
- subscribeToChannelFollowEventsa
- subscribeToChannelHypeTrainBeginEventsa
- subscribeToChannelHypeTrainEndEventsa
- subscribeToChannelHypeTrainProgressEventsa
- subscribeToChannelRedemptionAddEventsa
- subscribeToChannelRedemptionAddEventsForRewarda
- subscribeToChannelRedemptionUpdateEventsa
- subscribeToChannelRedemptionUpdateEventsForRewarda
- subscribeToChannelRewardAddEventsa
- subscribeToChannelRewardRemoveEventsa
- subscribeToChannelRewardRemoveEventsForRewarda
- subscribeToChannelRewardUpdateEventsa
- subscribeToChannelRewardUpdateEventsForRewarda
- subscribeToChannelSubscriptionEventsa
- subscribeToChannelUnbanEventsa
- subscribeToChannelUpdateEventsa
- subscribeToStreamOfflineEventsa
- subscribeToStreamOnlineEventsa
- subscribeToUserAuthorizationRevokeEventsa
- subscribeToUserUpdateEventsa
- unlistena
Constructor
new EventSubListener(apiClient, adapter, secret, config)
Creates a new EventSub listener.
Parameter | Type | Description |
---|---|---|
apiClient | ApiClient | The ApiClient instance to use for user info and API requests. |
adapter | ConnectionAdapter | The connection adapter. |
secret | string | The secret for Twitch to sign payloads with. |
config | EventSubConfig |
Methods
applyMiddleware(app)
asyncApplies middleware that handles EventSub notifications to a connect-compatible app (like express).
The express app should be started before this.
Parameter | Type | Description |
---|---|---|
app | ConnectCompatibleApp | The app the middleware should be applied to. |
listen(port)
asyncStarts the backing server and listens to incoming EventSub notifications.
Parameter | Type | Description |
---|---|---|
port | number | none |
resumeExistingSubscriptions()
asyncResumes subscriptions that are already registered with Twitch.
subscribeToChannelBanEvents(user, handler)
asyncSubscribes to events that represent a user getting banned from a channel.
Parameter | Type | Description |
---|---|---|
user | UserIdResolvable | The user for which to get notifications for when users get banned in their channel. |
handler | (event: EventSubChannelBanEvent) => void | 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 | Description |
---|---|---|
user | UserIdResolvable | The user for which to get notifications for about cheers they get. |
handler | (event: EventSubChannelCheerEvent) => void | 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 | Description |
---|---|---|
user | UserIdResolvable | The user for which to get notifications about their followers. |
handler | (event: EventSubChannelFollowEvent) => void | The function that will be called for any new notifications. |
subscribeToChannelHypeTrainBeginEvents(user, handler)
asyncSubscribes to events that represent a Hype Train beginning.
Parameter | Type | Description |
---|---|---|
user | UserIdResolvable | The user for which to get notifications about Hype Trains in their channel. |
handler | (data: EventSubChannelHypeTrainBeginEvent) => void | 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 | Description |
---|---|---|
user | UserIdResolvable | The user for which to get notifications about Hype Trains in their channel. |
handler | (data: EventSubChannelHypeTrainEndEvent) => void | 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 | Description |
---|---|---|
user | UserIdResolvable | The user for which to get notifications about Hype Trains in their channel. |
handler | (data: EventSubChannelHypeTrainProgressEvent) => void | 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 | Description |
---|---|---|
user | UserIdResolvable | The user for which to get notifications for when their rewards are redeemed. |
handler | (data: EventSubChannelRedemptionAddEvent) => void | 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 | Description |
---|---|---|
user | UserIdResolvable | The user for which to get notifications when their reward is redeemed. |
rewardId | string | The ID of the reward for which to get notifications when it is redeemed. |
handler | (data: EventSubChannelRedemptionAddEvent) => void | 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 | Description |
---|---|---|
user | UserIdResolvable | The user for which to get notifications for when they update a reward. |
handler | (data: EventSubChannelRedemptionUpdateEvent) => void | 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 | Description |
---|---|---|
user | UserIdResolvable | The user for which to get notifications for when they update the reward. |
rewardId | string | The ID of the reward for which to get notifications when it gets updated. |
handler | (data: EventSubChannelRedemptionUpdateEvent) => void | 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 | Description |
---|---|---|
user | UserIdResolvable | The user for which to get notifications for when they add a reward to their channel. |
handler | (data: EventSubChannelRewardEvent) => void | 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 | Description |
---|---|---|
user | UserIdResolvable | The user for which to get notifications for when they remove a reward. |
handler | (data: EventSubChannelRewardEvent) => void | 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 | Description |
---|---|---|
user | UserIdResolvable | The user for which to get notifications for when they remove the reward. |
rewardId | string | The ID of the reward to get notifications for when it is removed. |
handler | (data: EventSubChannelRewardEvent) => void | 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 | Description |
---|---|---|
user | UserIdResolvable | The user for which to get notifications for when they update a reward. |
handler | (data: EventSubChannelRewardEvent) => void | 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 | Description |
---|---|---|
user | UserIdResolvable | The user for which to get notifications for when they update the reward. |
rewardId | string | The ID of the reward for which to get notifications when it is updated. |
handler | (data: EventSubChannelRewardEvent) => void | 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 | Description |
---|---|---|
user | UserIdResolvable | The user for which to get notifications for about their subscribers. |
handler | (event: EventSubChannelSubscriptionEvent) => void | 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 | Description |
---|---|---|
user | UserIdResolvable | The user for which to get notifications for when users get unbanned in their channel. |
handler | (event: EventSubChannelUnbanEvent) => void | 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 | Description |
---|---|---|
user | UserIdResolvable | The user for which to get notifications about updates. |
handler | (event: EventSubChannelUpdateEvent) => void | The function that will be called for any new notifications. |
subscribeToStreamOfflineEvents(user, handler)
asyncSubscribes to events representing a stream going offline.
Parameter | Type | Description |
---|---|---|
user | UserIdResolvable | The user for which to get notifications about their streams going offline. |
handler | (event: EventSubStreamOfflineEvent) => void | The function that will be called for any new notifications. |
subscribeToStreamOnlineEvents(user, handler)
asyncSubscribes to events representing a stream going live.
Parameter | Type | Description |
---|---|---|
user | UserIdResolvable | The user for which to get notifications about their streams going live. |
handler | (event: EventSubStreamOnlineEvent) => void | 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 | Description |
---|---|---|
clientId | string | The Client ID for which to get notifications about authorization revocations. |
handler | (data: EventSubUserAuthorizationRevokeEvent) => void | 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 | Description |
---|---|---|
user | UserIdResolvable | The user for which to get notifications about account updates. |
handler | (data: EventSubUserUpdateEvent) => void | The function that will be called for any new notifications. |