twitcheasy-twitch-bottwitch-authtwitch-auth-tmitwitch-chat-clienttwitch-eventsubtwitch-pubsub-clienttwitch-webhooks

EventSubListener

A listener for the Twitch EventSub event distribution mechanism.

Overview

Constructor

new EventSubListener(apiClient, adapter, secret, config)

Creates a new EventSub listener.

ParameterTypeDescription
apiClientApiClient

The ApiClient instance to use for user info and API requests.

adapterConnectionAdapter

The connection adapter.

secretstring

The secret for Twitch to sign payloads with.

configEventSubConfig

Methods

applyMiddleware(app)

async

Applies middleware that handles EventSub notifications to a connect-compatible app (like express).

The express app should be started before this.

ParameterTypeDescription
appConnectCompatibleApp

The app the middleware should be applied to.

Return type: void

listen(port)

async

Starts the backing server and listens to incoming EventSub notifications.

ParameterTypeDescription
portnumbernone
Return type: void

resumeExistingSubscriptions()

async

Resumes subscriptions that are already registered with Twitch.

Return type: void

subscribeToChannelBanEvents(user, handler)

async

Subscribes to events that represent a user getting banned from a channel.

ParameterTypeDescription
userUserIdResolvable

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)

async

Subscribes to events that represent a user cheering some bits.

ParameterTypeDescription
userUserIdResolvable

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)

async

Subscribes to events that represent a user following a channel.

ParameterTypeDescription
userUserIdResolvable

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)

async

Subscribes to events that represent a Hype Train beginning.

ParameterTypeDescription
userUserIdResolvable

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)

async

Subscribes to events that represent the end of a Hype Train in a channel.

ParameterTypeDescription
userUserIdResolvable

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)

async

Subscribes to events that represent progress in a Hype Train in a channel.

ParameterTypeDescription
userUserIdResolvable

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)

async

Subscribes to events that represents a Channel Points reward being redeemed.

ParameterTypeDescription
userUserIdResolvable

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)

async

Subscribes to events that represent a specific Channel Points reward being redeemed.

ParameterTypeDescription
userUserIdResolvable

The user for which to get notifications when their reward is redeemed.

rewardIdstring

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)

async

Subscribes to events that represent a Channel Points reward being updated by a broadcaster.

ParameterTypeDescription
userUserIdResolvable

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)

async

Subscribes to events that represent a specific Channel Points reward being updated by a broadcaster.

ParameterTypeDescription
userUserIdResolvable

The user for which to get notifications for when they update the reward.

rewardIdstring

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)

async

Subscribes to events that represent a Channel Points reward being added to a channel.

ParameterTypeDescription
userUserIdResolvable

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)

async

Subscribes to events that represent a Channel Points reward being removed.

ParameterTypeDescription
userUserIdResolvable

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)

async

Subscribes to events that represent a specific Channel Points reward being removed.

ParameterTypeDescription
userUserIdResolvable

The user for which to get notifications for when they remove the reward.

rewardIdstring

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)

async

Subscribes to events that represent a Channel Points reward being updated.

ParameterTypeDescription
userUserIdResolvable

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)

async

Subscribes to events that represent a specific Channel Points reward being updated.

ParameterTypeDescription
userUserIdResolvable

The user for which to get notifications for when they update the reward.

rewardIdstring

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)

async

Subscribes to events that represent a user subscribing to a channel.

ParameterTypeDescription
userUserIdResolvable

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)

async

Subscribes to events that represent a user getting unbanned from a channel.

ParameterTypeDescription
userUserIdResolvable

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)

async

Subscribes to events representing a change in channel metadata, e.g. stream title or category.

ParameterTypeDescription
userUserIdResolvable

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)

async

Subscribes to events representing a stream going offline.

ParameterTypeDescription
userUserIdResolvable

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)

async

Subscribes to events representing a stream going live.

ParameterTypeDescription
userUserIdResolvable

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)

async

Subscribes to events that represent a user revoking authorization from an application.

ParameterTypeDescription
clientIdstring

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)

async

Subscribes to events that represent a user updating their account details.

ParameterTypeDescription
userUserIdResolvable

The user for which to get notifications about account updates.

handler(data: EventSubUserUpdateEvent) => void

The function that will be called for any new notifications.

unlisten()

async

Stops the backing server, suspending all active subscriptions.

Return type: void