Overview
Constructor
new PubSubClient(rootClient)
Creates a new PubSub client.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
rootClient | BasicPubSubClient | none | A previously existing PubSubClient instance. If not given, one will be created with the default options. |
Methods
onAutoModQueue(user, channel, callback)
asyncAdds a listener to AutoMod queue events to the client.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The user the event will be subscribed for. | |
channel | UserIdResolvable | 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)
asyncAdds a listener to bits events to the client.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | 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)
asyncAdds a listener to bits badge unlock events to the client.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | 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. |
onModAction(user, channel, callback)
asyncAdds a listener to mod action events to the client.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The user the event will be subscribed for. | |
channel | UserIdResolvable | none | The channel the event will be subscribed for. | |
callback | (message: PubSubChatModActionMessage) => void | none | A function to be called when a mod action event is sent to the user. It receives a PubSubChatModActionMessage object. |
onRedemption(user, callback)
asyncAdds a listener to redemption events to the client.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | 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)
asyncAdds a listener to subscription events to the client.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | 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)
asyncAdds a listener to user moderation events to the client.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none | The user the event will be subscribed for. | |
channel | UserIdResolvable | none | The channel to listen to. | |
callback | (message: PubSubSubscriptionMessage) => 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)
asyncAdds a listener to whisper events to the client.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | 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. |
registerUserListener(apiClient, user)
asyncAttaches a new user to the listener and returns the user ID for convenience.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
apiClient | ApiClient | none | The client that provides authentication for the user. | |
user | UserIdResolvable | none | The user that the client will be attached to. This should only be passed manually if you fetched the token info for the If not given, the user will be determined from the |