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

WebHookListener

A WebHook listener you can track changes in various channel and user data with.

Overview

Constructor

new WebHookListener(apiClient, adapter, config)

Creates a new WebHook 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.

config WebHookConfig {}

Methods

applyMiddleware(app)

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

Parameter Type Required Default Description
app ConnectCompatibleApp none

The app the middleware should be applied to.

Return type: void

listen()

async

Starts the backing server and listens to incoming WebHook notifications.

Return type: void

subscribeToBanEvents(broadcaster, handler, user, validityInSeconds)

async

Subscribes to events representing a ban or unban.

Parameter Type Required Default Description
broadcaster UserIdResolvable none

The broadcaster for which to get notifications about bans or unbans in their channel.

handler (banEvent: HelixBanEvent) => void none

The function that will be called for any new notifications.

user UserIdResolvable none

The user that events will be sent for. If not given, events will be sent for all users.

validityInSeconds ?number this._defaultHookValidity

The validity of the WebHook, in seconds.

Please note that this doesn't mean that you don't get any notifications after the given time. The hook will be automatically refreshed.

This is meant for debugging issues. Please don't set it unless you know what you're doing.

Return type: Subscription

subscribeToExtensionTransactions(extensionId, handler, validityInSeconds)

async

Subscribes to extension transactions.

Parameter Type Required Default Description
extensionId string none

The extension ID for which to get notifications about transactions.

handler (transaction: HelixExtensionTransaction) => void none

The function that will be called for any new notifications.

validityInSeconds ?number this._defaultHookValidity

The validity of the WebHook, in seconds.

Please note that this doesn't mean that you don't get any notifications after the given time. The hook will be automatically refreshed.

This is meant for debugging issues. Please don't set it unless you know what you're doing.

Return type: Subscription

subscribeToFollowsFromUser(user, handler, validityInSeconds)

async

Subscribes to events representing a user following other users.

Parameter Type Required Default Description
user UserIdResolvable none

The user for which to get notifications about the users they will follow.

handler (follow: HelixFollow) => void none

The function that will be called for any new notifications.

validityInSeconds ?number this._defaultHookValidity

The validity of the WebHook, in seconds.

Please note that this doesn't mean that you don't get any notifications after the given time. The hook will be automatically refreshed.

This is meant for debugging issues. Please don't set it unless you know what you're doing.

Return type: Subscription

subscribeToFollowsToUser(user, handler, validityInSeconds)

async

Subscribes to events representing a user being followed by other users.

Parameter Type Required Default Description
user UserIdResolvable none

The user for which to get notifications about the users they will be followed by.

handler (follow: HelixFollow) => void none

The function that will be called for any new notifications.

validityInSeconds ?number this._defaultHookValidity

The validity of the WebHook, in seconds.

Please note that this doesn't mean that you don't get any notifications after the given time. The hook will be automatically refreshed.

This is meant for debugging issues. Please don't set it unless you know what you're doing.

Return type: Subscription

subscribeToHypeTrainEvents(broadcaster, handler, validityInSeconds)

async

Subscribes to events representing a Hype Train event.

Parameter Type Required Default Description
broadcaster UserIdResolvable none

The broadcaster / channel for which to get notifications about the Hype Train events.

handler (hypeTrain: HelixHypeTrainEvent) => void none

The function that will be called for any new notifications.

validityInSeconds ?number this._defaultHookValidity

The validity of the WebHook, in seconds.

Please note that this doesn't mean that you don't get any notifications after the given time. The hook will be automatically refreshed.

This is meant for debugging issues. Please don't set it unless you know what you're doing.

Return type: Subscription

subscribeToModeratorEvents(broadcaster, handler, user, validityInSeconds)

async

Subscribes to events representing a user gaining or losing moderator privileges in a channel.

Parameter Type Required Default Description
broadcaster UserIdResolvable none

The broadcaster for which to get notifications about moderator changes in their channel.

handler (modEvent: HelixModeratorEvent) => void none

The function that will be called for any new notifications.

user UserIdResolvable none

The user that events will be sent for. If not given, events will be sent for all users.

validityInSeconds ?number this._defaultHookValidity

The validity of the WebHook, in seconds.

Please note that this doesn't mean that you don't get any notifications after the given time. The hook will be automatically refreshed.

This is meant for debugging issues. Please don't set it unless you know what you're doing.

Return type: Subscription

subscribeToStreamChanges(user, handler, validityInSeconds)

async

Subscribes to events representing a stream changing, i.e. going live, offline or changing its title or category.

Parameter Type Required Default Description
user UserIdResolvable none

The user for which to get notifications about their streams changing.

handler (stream: HelixStream) => void none

The function that will be called for any new notifications.

validityInSeconds ?number this._defaultHookValidity

The validity of the WebHook, in seconds.

Please note that this doesn't mean that you don't get any notifications after the given time. The hook will be automatically refreshed.

This is meant for debugging issues. Please don't set it unless you know what you're doing.

Return type: Subscription

subscribeToSubscriptionEvents(broadcaster, handler, validityInSeconds)

async

Subscribes to events representing the start or end of a channel subscription.

Parameter Type Required Default Description
broadcaster UserIdResolvable none

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

handler (subscriptionEvent: HelixSubscriptionEvent) => void none

The function that will be called for any new notifications.

validityInSeconds ?number this._defaultHookValidity

The validity of the WebHook, in seconds.

Please note that this doesn't mean that you don't get any notifications after the given time. The hook will be automatically refreshed.

This is meant for debugging issues. Please don't set it unless you know what you're doing.

Return type: Subscription

subscribeToUserChanges(user, handler, withEmail, validityInSeconds)

async

Subscribes to events representing a user changing a public setting or their email address.

Parameter Type Required Default Description
user UserIdResolvable none

The user for which to get notifications about changing a setting.

handler (user: HelixUser) => void none

The function that will be called for any new notifications.

withEmail boolean false

Whether to subscribe to email address changes. This requires an additional scope (user:read:email).

validityInSeconds ?number this._defaultHookValidity

The validity of the WebHook, in seconds.

Please note that this doesn't mean that you don't get any notifications after the given time. The hook will be automatically refreshed.

This is meant for debugging issues. Please don't set it unless you know what you're doing.

Return type: Subscription

unlisten()

async

Stops the backing server, suspending all active subscriptions.

Return type: void