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. |
listen()
asyncStarts the backing server and listens to incoming WebHook notifications.
subscribeToBanEvents(broadcaster, handler, user, validityInSeconds)
asyncSubscribes 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. |
subscribeToExtensionTransactions(extensionId, handler, validityInSeconds)
asyncSubscribes 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. |
subscribeToFollowsFromUser(user, handler, validityInSeconds)
asyncSubscribes 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. |
subscribeToFollowsToUser(user, handler, validityInSeconds)
asyncSubscribes 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. |
subscribeToHypeTrainEvents(broadcaster, handler, validityInSeconds)
asyncSubscribes 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. |
subscribeToModeratorEvents(broadcaster, handler, user, validityInSeconds)
asyncSubscribes 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. |
subscribeToStreamChanges(user, handler, validityInSeconds)
asyncSubscribes 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. |
subscribeToSubscriptionEvents(broadcaster, handler, validityInSeconds)
asyncSubscribes 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. |
subscribeToUserChanges(user, handler, withEmail, validityInSeconds)
asyncSubscribes 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. |