Overview
Methods
- applyMiddlewarea
- listena
- resumeExistingSubscriptionsa
- subscribeToChannelBanEventsa
- subscribeToChannelCheerEventsa
- subscribeToChannelFollowEventsa
- subscribeToChannelHypeTrainBeginEventsa
- subscribeToChannelHypeTrainEndEventsa
- subscribeToChannelHypeTrainProgressEventsa
- subscribeToChannelRaidEventsFroma
- subscribeToChannelRaidEventsToa
- 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 | 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 |
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 | 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()
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 | 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. |
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. |
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. |
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. |
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. |