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

EventSubListener

A listener for the Twitch EventSub event distribution mechanism.

Overview

Constructor

new EventSubListener(apiClient, adapter, secret, config)

Creates a new EventSub listener.

ParameterTypeRequiredDefaultDescription
apiClientApiClientnone

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

adapterConnectionAdapternone

The connection adapter.

secretstringnone

The secret for Twitch to sign payloads with.

configEventSubConfignone
config.loggerPartial<LoggerOptions>none

Options to pass to the logger.

Methods

applyMiddleware(app)

async
Deprecated.

Use EventSubMiddleware#applyToApp instead.

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

The express app should be started before this.

ParameterTypeRequiredDefaultDescription
appConnectCompatibleAppnone

The app the middleware should be applied to.

Return type: void

listen(port)

async

Starts the backing server and listens to incoming EventSub notifications.

ParameterTypeRequiredDefaultDescription
portnumbernonenone
Return type: void

resumeExistingSubscriptions()

async
Deprecated.

No replacement; this should only be used with middleware.

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.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user for which to get notifications for when users get banned in their channel.

handler(event: EventSubChannelBanEvent) => voidnone

The function that will be called for any new notifications.

subscribeToChannelCheerEvents(user, handler)

async

Subscribes to events that represent a user cheering some bits.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user for which to get notifications for about cheers they get.

handler(event: EventSubChannelCheerEvent) => voidnone

The function that will be called for any new notifications.

subscribeToChannelFollowEvents(user, handler)

async

Subscribes to events that represent a user following a channel.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user for which to get notifications about their followers.

handler(event: EventSubChannelFollowEvent) => voidnone

The function that will be called for any new notifications.

subscribeToChannelHypeTrainBeginEvents(user, handler)

async

Subscribes to events that represent a Hype Train beginning.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user for which to get notifications about Hype Trains in their channel.

handler(data: EventSubChannelHypeTrainBeginEvent) => voidnone

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.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user for which to get notifications about Hype Trains in their channel.

handler(data: EventSubChannelHypeTrainEndEvent) => voidnone

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.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user for which to get notifications about Hype Trains in their channel.

handler(data: EventSubChannelHypeTrainProgressEvent) => voidnone

The function that will be called for any new notifications.

subscribeToChannelModeratorAddEvents(user, handler)

async

Subscribes to events that represent a user getting moderator permissions in a channel.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user for which to get notifications for when users get moderator permissions in their channel.

handler(event: EventSubChannelModeratorEvent) => voidnone

The function that will be called for any new notifications.

subscribeToChannelModeratorRemoveEvents(user, handler)

async

Subscribes to events that represent a user losing moderator permissions in a channel.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user for which to get notifications for when users lose moderator permissions in their channel.

handler(event: EventSubChannelModeratorEvent) => voidnone

The function that will be called for any new notifications.

subscribeToChannelPollBeginEvents(user, handler)

async

Subscribes to events that represent a poll starting in a channel.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The broadcaster for which to receive poll begin events.

handler(data: EventSubChannelPollBeginEvent) => voidnone

The function that will be called for any new notifications.

subscribeToChannelPollEndEvents(user, handler)

async

Subscribes to events that represent a poll ending in a channel.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The broadcaster for which to receive poll end events.

handler(data: EventSubChannelPollEndEvent) => voidnone

The function that will be called for any new notifications.

subscribeToChannelPollProgressEvents(user, handler)

async

Subscribes to events that represent a poll being voted on in a channel.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The broadcaster for which to receive poll progress events.

handler(data: EventSubChannelPollProgressEvent) => voidnone

The function that will be called for any new notifications.

subscribeToChannelPredictionBeginEvents(user, handler)

async

Subscribes to events that represent a prediction starting in a channel.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The broadcaster for which to receive prediction begin events.

handler(data: EventSubChannelPredictionBeginEvent) => voidnone

The function that will be called for any new notifications.

subscribeToChannelPredictionEndEvents(user, handler)

async

Subscribes to events that represent a prediction ending in a channel.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The broadcaster for which to receive prediction end events.

handler(data: EventSubChannelPredictionEndEvent) => voidnone

The function that will be called for any new notifications.

subscribeToChannelPredictionLockEvents(user, handler)

async

Subscribes to events that represent a prediction being locked in a channel.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The broadcaster for which to receive prediction lock events.

handler(data: EventSubChannelPredictionLockEvent) => voidnone

The function that will be called for any new notifications.

subscribeToChannelPredictionProgressEvents(user, handler)

async

Subscribes to events that represent a prediction being voted on in a channel.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The broadcaster for which to receive prediction progress events.

handler(data: EventSubChannelPredictionProgressEvent) => voidnone

The function that will be called for any new notifications.

subscribeToChannelRaidEventsFrom(user, handler)

async

Subscribes to events that represent a broadcaster raiding another broadcaster.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The broadcaster for which to get outgoing raid notifications.

handler(event: EventSubChannelRaidEvent) => voidnone

The function that will be called for any new notifications.

subscribeToChannelRaidEventsTo(user, handler)

async

Subscribes to events that represent a broadcaster being raided by another broadcaster.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The broadcaster for which to get incoming raid notifications.

handler(event: EventSubChannelRaidEvent) => voidnone

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.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user for which to get notifications for when their rewards are redeemed.

handler(data: EventSubChannelRedemptionAddEvent) => voidnone

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.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

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

rewardIdstringnone

The ID of the reward for which to get notifications when it is redeemed.

handler(data: EventSubChannelRedemptionAddEvent) => voidnone

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.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

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

handler(data: EventSubChannelRedemptionUpdateEvent) => voidnone

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.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

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

rewardIdstringnone

The ID of the reward for which to get notifications when it gets updated.

handler(data: EventSubChannelRedemptionUpdateEvent) => voidnone

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.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user for which to get notifications for when they add a reward to their channel.

handler(data: EventSubChannelRewardEvent) => voidnone

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.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

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

handler(data: EventSubChannelRewardEvent) => voidnone

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.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

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

rewardIdstringnone

The ID of the reward to get notifications for when it is removed.

handler(data: EventSubChannelRewardEvent) => voidnone

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.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

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

handler(data: EventSubChannelRewardEvent) => voidnone

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.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

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

rewardIdstringnone

The ID of the reward for which to get notifications when it is updated.

handler(data: EventSubChannelRewardEvent) => voidnone

The function that will be called for any new notifications.

subscribeToChannelSubscriptionEndEvents(user, handler)

async

Subscribes to events that represent a user's subscription to a channel ending.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user for which to get notifications for about ending subscriptions.

handler(event: EventSubChannelSubscriptionEndEvent) => voidnone

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.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user for which to get notifications for about their subscribers.

handler(event: EventSubChannelSubscriptionEvent) => voidnone

The function that will be called for any new notifications.

subscribeToChannelSubscriptionGiftEvents(user, handler)

async

Subscribes to events that represent a user gifting a subscription to a channel to someone else.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user for which to get notifications for about subscriptions people gift in their channel.

handler(event: EventSubChannelSubscriptionGiftEvent) => voidnone

The function that will be called for any new notifications.

subscribeToChannelSubscriptionMessageEvents(user, handler)

async

Subscribes to events that represent a user's subscription to a channel being announced.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user for which to get notifications for about announced subscriptions.

handler(event: EventSubChannelSubscriptionMessageEvent) => voidnone

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.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user for which to get notifications for when users get unbanned in their channel.

handler(event: EventSubChannelUnbanEvent) => voidnone

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.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user for which to get notifications about updates.

handler(event: EventSubChannelUpdateEvent) => voidnone

The function that will be called for any new notifications.

subscribeToExtensionBitsTransactionCreateEvents(clientId, handler)

async

Subscribes to events that represent a Bits transaction in an extension.

ParameterTypeRequiredDefaultDescription
clientIdstringnone

The Client ID of the extension for which to get notifications for about Bits transactions.

handler(event: EventSubExtensionBitsTransactionCreateEvent) => voidnone

The function that will be called for any new notifications.

subscribeToStreamOfflineEvents(user, handler)

async

Subscribes to events representing a stream going offline.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user for which to get notifications about their streams going offline.

handler(event: EventSubStreamOfflineEvent) => voidnone

The function that will be called for any new notifications.

subscribeToStreamOnlineEvents(user, handler)

async

Subscribes to events representing a stream going live.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user for which to get notifications about their streams going live.

handler(event: EventSubStreamOnlineEvent) => voidnone

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.

ParameterTypeRequiredDefaultDescription
clientIdstringnone

The Client ID for which to get notifications about authorization revocations.

handler(data: EventSubUserAuthorizationRevokeEvent) => voidnone

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.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user for which to get notifications about account updates.

handler(data: EventSubUserUpdateEvent) => voidnone

The function that will be called for any new notifications.

unlisten()

async

Stops the backing server, suspending all active subscriptions.

Return type: void