MicroWazzle

Untitled

Feb 25th, 2022
974
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { RefreshingAuthProvider } from 'twurple/auth';
  2. import { ChatClient } from 'twurple/chat';
  3. import { promises as fs } from 'fs';
  4. import { Chalk } from 'chalk';
  5.  
  6. const chalk = new Chalk({level:2});
  7.  
  8. async function main() {
  9.     const clientId = '';
  10.     const clientSecret = '';
  11.     const tokenData = JSON.parse(await fs.readFile('./tokens.json', 'UTF-8'));
  12.     const authProvider = new RefreshingAuthProvider(
  13.         {
  14.             clientId,
  15.             clientSecret,
  16.             onRefresh: async newTokenData => await fs.writeFile('./tokens.json', JSON.stringify(newTokenData, null, 4), 'UTF-8')
  17.         },
  18.         tokenData
  19.     );
  20.  
  21.     const chatClient = new ChatClient({ authProvider, channels: ['sodapoppin', 'dexterous_alloy', 'ashunera'] });
  22.     await chatClient.connect();
  23.  
  24.     chatClient.onMessage((channel, user, message) => {
  25.         if (message === ';test') {
  26.             chatClient.say(channel, 'Test successful');
  27.     }});
  28. }
  29. main();
  30.  
Advertisement
Add Comment
Please, Sign In to add comment