TwitchPubSub

TwitchPubSub

TwitchPubSub The Twitch PubSub implementation, as described in https://dev.twitch.tv/docs/pubsub/ .

Constructor

new TwitchPubSub(config)

Source:
Parameters:
Name Type Description
config object

The config object.

Name Type Description
logger object

The logger instance. If empty, the default logger will be used.

authToken string

The Twitch with OAuth token.

reconnect boolean

Reconnect to Twitch PubSub when disconnected from server. Default: false

Methods

connect() → {Promise}

Connects to the Twitch PubSub

Source:
Returns:
Type:
Promise

Promise for the connection.

disconnect() → {Promise}

Disconnects to the Twitch PubSub

Source:
Returns:
Type:
Promise

Promise for the disconnection.

reconnect() → {Promise}

Reconnect to WebSub and resubscribe to the already added topics.

Source:
Returns:
Type:
Promise

subscribe(types, id, authToken) → {Promise}

Subscribe to a topic based on the type.

Source:
Parameters:
Name Type Description
types Array.<String>

The types array. Valid options: 'bits', 'subscription', 'commerce', 'whisper'

id String

The channel/user ID.

authToken String

The oauth token with the necessary scopes.

Returns:
Type:
Promise

The subscription promise that will be resolved when it receives the response.