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

PubSubClient

A high level PubSub client attachable to a multiple users.

Overview

Constructor

new PubSubClient(rootClient)

Creates a new PubSub client.

ParameterTypeRequiredDefaultDescription
rootClientBasicPubSubClientnone

A previously existing PubSubClient instance.

If not given, one will be created with the default options.

Methods

onAutoModQueue(user, channel, callback)

async

Adds a listener to AutoMod queue events to the client.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user the event will be subscribed for.

channelUserIdResolvablenone

The channel to listen to.

callback(message: PubSubAutoModQueueMessage) => voidnone

A function to be called when an AutoMod queue event is sent to the user.

It receives a PubSubAutoModQueueMessage object.

Return type: PubSubListener<never>

onBits(user, callback)

async

Adds a listener to bits events to the client.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user the event will be subscribed for.

callback(message: PubSubBitsMessage) => voidnone

A function to be called when a bits event happens in the user's channel.

It receives a PubSubBitsMessage object.

Return type: PubSubListener<never>

onBitsBadgeUnlock(user, callback)

async

Adds a listener to bits badge unlock events to the client.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user the event will be subscribed for.

callback(message: PubSubBitsBadgeUnlockMessage) => voidnone

A function to be called when a bit badge is unlocked in the user's channel.

It receives a PubSubBitsBadgeUnlockMessage object.

Return type: PubSubListener<never>

onModAction(user, channel, callback)

async

Adds a listener to mod action events to the client.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user the event will be subscribed for.

channelUserIdResolvablenone

The channel the event will be subscribed for.

callback(message: PubSubChatModActionMessage) => voidnone

A function to be called when a mod action event is sent to the user.

It receives a PubSubChatModActionMessage object.

Return type: PubSubListener<never>

onRedemption(user, callback)

async

Adds a listener to redemption events to the client.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user the event will be subscribed for.

callback(message: PubSubRedemptionMessage) => voidnone

A function to be called when a channel point reward is redeemed in the user's channel.

It receives a PubSubRedemptionMessage object.

Return type: PubSubListener<never>

onSubscription(user, callback)

async

Adds a listener to subscription events to the client.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user the event will be subscribed for.

callback(message: PubSubSubscriptionMessage) => voidnone

A function to be called when a subscription event happens in the user's channel.

It receives a PubSubSubscriptionMessage object.

Return type: PubSubListener<never>

onUserModeration(user, channel, callback)

async

Adds a listener to user moderation events to the client.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user the event will be subscribed for.

channelUserIdResolvablenone

The channel to listen to.

callback(message: PubSubSubscriptionMessage) => voidnone

A function to be called when a user moderation event is sent to the user.

It receives a PubSubUserModerationNotificationMessage object.

Return type: PubSubListener<never>

onWhisper(user, callback)

async

Adds a listener to whisper events to the client.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user the event will be subscribed for.

callback(message: PubSubWhisperMessage) => voidnone

A function to be called when a whisper is sent to the user.

It receives a PubSubWhisperMessage object.

Return type: PubSubListener<never>

registerUserListener(apiClient, user)

async

Attaches a new user to the listener and returns the user ID for convenience.

ParameterTypeRequiredDefaultDescription
apiClientApiClientnone

The client that provides authentication for the user.

userUserIdResolvablenone

The user that the client will be attached to.

This should only be passed manually if you fetched the token info for the apiClient before.

If not given, the user will be determined from the apiClient.

Return type: string