Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const tmi = require('tmi.js');
- require('dotenv').config();
- const options = {
- options: {
- debug: true
- },
- identity: {
- username: process.env.OAUTH_USERNAME,
- password: process.env.OAUTH_PASSWORD
- },
- connection: {
- reconnect: true
- },
- channels: [`instak`]
- };
- const client = new tmi.client(options);
- client.on(`chat`, (channel, userstate, message/*, self */) => {
- console.log(userstate.username); //This logs my userstate, I can see the username which is passed on correctly.
- switch (message) {
- case `!kluiten`:
- fetch(`http://localhost:8000/api/users/${userstate.username}`) // fetch from Express.js server
- .then(response => response.json())
- .then(result => {
- console.log(`USERSTATE IS`, userstate);
- client.action(channel, `${userstate[`display-name`]}, you've got ${result.instakluiten} instakluiten.`);
- });
- break;
- default:
- break;
- }
- });
- // Connect the client to the server..
- client.connect();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement