Skip to content

WebhookSubscription

A subscription created within a WebhookConnection.

Extends

Type parameters

Type parameterValue
T extends SubscriptionTypesSubscriptionTypes

Constructors

new WebhookSubscription()

1
new WebhookSubscription<T>(
2
connection: WebhookConnection,
3
options: SubscriptionOptions<T>,
4
data: PostEventSubSubscription,
5
secret: string): WebhookSubscription<T>

Builds up a new WebhookSubscription.

Parameters

ParameterTypeDescription
connectionWebhookConnectionThe connection used for this subscription.
optionsSubscriptionOptions<T>The options for the subscription.
dataPostEventSubSubscriptionThe data for the subscription.
secretstringThe secret used for creating this subscription.

Returns

WebhookSubscription<T>

Overrides

Subscription.constructor

Source

twitchfy/packages/eventsub/src/webhook/structures/WebhookSubscription.ts:38

Properties

PropertyModifierTypeDescriptionInherited from
callbacksreadonlyWebhookSubscriptionCallbackManager<T>The callbacks for this subscription.-
connectionreadonlyWebhookConnectionThe connection used for this subscription.-
costreadonlynumberThe cost of the subscription. If the subscription doesn’t needs an authorization this could be 1 (or 0 if the target user has authorized within your application) if not it will be 0. Maximum accumulated cost for webhooks subscriptions is 10000 while for websocket subscriptions is 3.Subscription.cost
createdAtreadonlyDateThe date when the subscription was created.Subscription.createdAt
idreadonlystringThe ID of the subscription.Subscription.id
noncepublicstringThe nonce of the subscription. An unique identifier which you can set to separate same type subscriptions.Subscription.nonce
optionsreadonlySubscriptionTypeOptions[T]The options used to create the subscription.Subscription.options
secretreadonlystringThe secret used for creating this subscription.-
statuspublicstringThe status of the subscription. Normally is ‘enabled’.Subscription.status
typereadonlyTThe type of the subscription.Subscription.type
versionreadonlystringThe version of the subscription. This version is the latest version of the subscription type.Subscription.version

Methods

checkSubscriptionType()

1
checkSubscriptionType<U>(type: U): this is WebhookSubscription<U>

Checks if the subscription is of a specific type.

Type parameters

Type parameter
U extends SubscriptionTypes

Parameters

ParameterTypeDescription
typeUThe type to check.

Returns

this is WebhookSubscription<U>

Whether the subscription is of the type.

Source

twitchfy/packages/eventsub/src/webhook/structures/WebhookSubscription.ts:70


delete()

1
delete(): Promise<void>

Deletes the subscription.

Returns

Promise<void>

Source

twitchfy/packages/eventsub/src/webhook/structures/WebhookSubscription.ts:77


onMessage()

1
onMessage(callback: WebhookSubscriptionCallback<T>): void

Adds a new callback to the subscription. This callback will be executed when a message within this subscription is received.

Parameters

ParameterTypeDescription
callbackWebhookSubscriptionCallback<T>The callback to add.

Returns

void

Source

twitchfy/packages/eventsub/src/webhook/structures/WebhookSubscription.ts:59