Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Instantiate clients.
const { api, chat } = new TwitchJs({ token, username });
// Get featured streams.
api.get('streams/featured', { version: 'kraken' }).then(response => {
console.log(response);
// Do stuff ...
});
const handleMessage = message => {
console.log(message);
// Do other stuff ...
};
// Listen for all events.
chat.on(TwitchJs.Chat.Events.ALL, handleMessage);
// Connect ...
chat.connect().then(() => {
// ... and then join the channel.
chat.join(channel);
});