Add a middleware to your Express server so it will receive EventSub notifications.
Must be called before TwitchChannel.connect.
See the EventSub paragraph in TwitchChannel.
Connect to the IRC chat, subscribe to EventSub, start emitting events.
Disconnect from every source and stop emitting events.
Subscribe to an event type
the event to subscribe
the handler
Subscribe to an event type
the event to subscribe
the handler
Subscribe to an event type
the event to subscribe
the handler
Subscribe to an event type
the event to subscribe
the handler
Subscribe to an event type
the event to subscribe
the handler
Subscribe to an event type
the event to subscribe
the handler
Subscribe to an event type
the event to subscribe
the handler
Subscribe to an event type
the event to subscribe
the handler
Subscribe to an event type
the event to subscribe
the handler
Subscribe to an event type
the event to subscribe
the handler
Subscribe to an event type
the event to subscribe
the handler
Subscribe to an event type
the event to subscribe
the handler
Subscribe to an event type
the event to subscribe
the handler
Subscribe to an event type
the event to subscribe
the handler
Subscribe to an event type
the event to subscribe
the handler
Subscribe to an event type
the event to subscribe
the handler
Subscribe to an event type
the event to subscribe
the handler
Subscribe to an event type
the event to subscribe
the handler
Subscribe to an event type
the event to subscribe
the handler
Subscribe to an event type
the event to subscribe
the handler
Subscribe to an event type
the event to subscribe
the handler
Subscribe to an event type
the event to subscribe
the handler
Subscribe to an event type
the event to subscribe
the handler
Subscribe to an event type
the event to subscribe
the handler
Subscribe to an event type
the event to subscribe
the handler
Generated using TypeDoc
A small JavaScript library to listen to various events that can happen on a twitch channel (chat messages, raids, follows, subscriptions…).
This library acts as a layer on top of various twitch APIs (currently: IRC and EventSub) so you only have to interact with a single EventEmitter that emits uniform events.
The event objects are kept simple and without surprises.
NPM - GitHub
Example
Connecting to sources
Depending on which config you provide, the lib will be able to emit many types of events.
EventSub
EventSub is a system where twitch sends HTTPS requests to notify your server.
In order to make it work, your server must be reachable from the internet with HTTPS and a domain name (you may need a reverse proxy: this lib won't handle the TLS layer and will listen to HTTP requests only).
From here you have 2 choices:
Either you provide both OptionalConfig.callbackUrl and OptionalConfig.port, and the lib will start an http server that will listen to twitch's requests on the provided port.
Or, if you already have an Express-like server, you provide only OptionalConfig.callbackUrl and you call TwitchChannel.applyEventSubMiddleware on your server, and the lib will add a middleware to your server so it receives twitch's requests.
Some events require your client to be authorized by the channel's owner. To do that, you must create an OAuth flow where the user generates a token using your app's client id and containing the required scopes. Once the channel's owner have authorized your app, you don't need the resulting token.
The needed scopes are:
channel:moderate channel:read:hype_train channel:read:redemptions channel:read:subscriptions
.