Overview
Events
Constructor
new PubSubClient(config)
Creates a new PubSub client.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
config | PubSubClientConfig | none | The client configuration. |
Events
onListenError((handler, error, userInitiated) => { /* ... */ })
Fires when listening to a topic fails.
Parameter | Type | Description |
---|---|---|
handler | PubSubHandler<PubSubMessage> | none |
error | Error | The error. |
userInitiated | boolean | Whether the listen was directly initiated by a user. The other case would happen in cases like re-sending listen packets after a reconnect. |
Methods
onAutoModQueue(user, channel, callback)
Adds a handler to AutoMod queue events to the client.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable A user ID or a user or channel object. This is not a user name. Please use HelixUserApi#getUserByName to fetch a user object by name. Aliased type: string | number | UserIdResolvableType | none | The user the event will be subscribed for. | |
channel | UserIdResolvable A user ID or a user or channel object. This is not a user name. Please use HelixUserApi#getUserByName to fetch a user object by name. Aliased type: string | number | UserIdResolvableType | none | The channel to listen to. | |
callback | (message: PubSubAutoModQueueMessage) => void | none | A function to be called when an AutoMod queue event is sent to the user. It receives a PubSubAutoModQueueMessage object. |
onBits(user, callback)
Adds a handler to bits events to the client.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable A user ID or a user or channel object. This is not a user name. Please use HelixUserApi#getUserByName to fetch a user object by name. Aliased type: string | number | UserIdResolvableType | none | The user the event will be subscribed for. | |
callback | (message: PubSubBitsMessage) => void | none | A function to be called when a bits event happens in the user's channel. It receives a PubSubBitsMessage object. |
onBitsBadgeUnlock(user, callback)
Adds a handler to bits badge unlock events to the client.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable A user ID or a user or channel object. This is not a user name. Please use HelixUserApi#getUserByName to fetch a user object by name. Aliased type: string | number | UserIdResolvableType | none | The user the event will be subscribed for. | |
callback | (message: PubSubBitsBadgeUnlockMessage) => void | none | A function to be called when a bit badge is unlocked in the user's channel. It receives a PubSubBitsBadgeUnlockMessage object. |
onCustomTopic(user, topic, callback, scope, channel)
Adds a handler for arbitrary/undocumented events to the client.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable A user ID or a user or channel object. This is not a user name. Please use HelixUserApi#getUserByName to fetch a user object by name. Aliased type: string | number | UserIdResolvableType | none | The user the event will be subscribed for. | |
topic | string | none | The topic to subscribe to. | |
callback | (message: PubSubCustomMessage) => void | none | A function to be called when a custom event is sent to the user. It receives a PubSubCustomMessage object. | |
scope | string | none | An optional scope if the topic requires it. | |
channel | UserIdResolvable A user ID or a user or channel object. This is not a user name. Please use HelixUserApi#getUserByName to fetch a user object by name. Aliased type: string | number | UserIdResolvableType | none | An optional second userId if the topic requires it, usually a channel. |
onLowTrustUser(channel, user, callback)
Adds a handler to low-trust users events to the client.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
channel | UserIdResolvable A user ID or a user or channel object. This is not a user name. Please use HelixUserApi#getUserByName to fetch a user object by name. Aliased type: string | number | UserIdResolvableType | none | The channel the event will be subscribed for. | |
user | UserIdResolvable A user ID or a user or channel object. This is not a user name. Please use HelixUserApi#getUserByName to fetch a user object by name. Aliased type: string | number | UserIdResolvableType | none | The user the event will be subscribed for. | |
callback | (message: PubSubLowTrustUserMessage ) => voidAliased type: PubSubLowTrustUserTreatmentMessage | PubSubLowTrustUserChatMessage | none | A function to be called when a low-trust user event is sent to the user. |
onModAction(user, channel, callback)
Adds a handler to mod action events to the client.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable A user ID or a user or channel object. This is not a user name. Please use HelixUserApi#getUserByName to fetch a user object by name. Aliased type: string | number | UserIdResolvableType | none | The user the event will be subscribed for. | |
channel | UserIdResolvable A user ID or a user or channel object. This is not a user name. Please use HelixUserApi#getUserByName to fetch a user object by name. Aliased type: string | number | UserIdResolvableType | none | The channel the event will be subscribed for. | |
callback | (message: PubSubModActionMessage) => void | none | A function to be called when a mod action event is sent to the user. It can receive any kind of {@link PubSubModActionMessage} object. |
onRedemption(user, callback)
Adds a handler to redemption events to the client.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable A user ID or a user or channel object. This is not a user name. Please use HelixUserApi#getUserByName to fetch a user object by name. Aliased type: string | number | UserIdResolvableType | none | The user the event will be subscribed for. | |
callback | (message: PubSubRedemptionMessage) => void | none | A function to be called when a channel point reward is redeemed in the user's channel. It receives a PubSubRedemptionMessage object. |
onSubscription(user, callback)
Adds a handler to subscription events to the client.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable A user ID or a user or channel object. This is not a user name. Please use HelixUserApi#getUserByName to fetch a user object by name. Aliased type: string | number | UserIdResolvableType | none | The user the event will be subscribed for. | |
callback | (message: PubSubSubscriptionMessage) => void | none | A function to be called when a subscription event happens in the user's channel. It receives a PubSubSubscriptionMessage object. |
onUserModeration(user, channel, callback)
Adds a handler to user moderation events to the client.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable A user ID or a user or channel object. This is not a user name. Please use HelixUserApi#getUserByName to fetch a user object by name. Aliased type: string | number | UserIdResolvableType | none | The user the event will be subscribed for. | |
channel | UserIdResolvable A user ID or a user or channel object. This is not a user name. Please use HelixUserApi#getUserByName to fetch a user object by name. Aliased type: string | number | UserIdResolvableType | none | The channel to listen to. | |
callback | (message: PubSubUserModerationNotificationMessage) => void | none | A function to be called when a user moderation event is sent to the user. It receives a PubSubUserModerationNotificationMessage object. |
onWhisper(user, callback)
Adds a handler to whisper events to the client.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable A user ID or a user or channel object. This is not a user name. Please use HelixUserApi#getUserByName to fetch a user object by name. Aliased type: string | number | UserIdResolvableType | none | The user the event will be subscribed for. | |
callback | (message: PubSubWhisperMessage) => void | none | A function to be called when a whisper is sent to the user. It receives a PubSubWhisperMessage object. |
removeHandler(handler)
Removes a handler from the client.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
handler | PubSubHandler<never> | none | A handler returned by one of the |