Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { RefreshingAuthProvider } from 'twurple/auth';
- import { ChatClient } from 'twurple/chat';
- import { promises as fs } from 'fs';
- import { Chalk } from 'chalk';
- const chalk = new Chalk({level:2});
- async function main() {
- const clientId = '';
- const clientSecret = '';
- const tokenData = JSON.parse(await fs.readFile('./tokens.json', 'UTF-8'));
- const authProvider = new RefreshingAuthProvider(
- {
- clientId,
- clientSecret,
- onRefresh: async newTokenData => await fs.writeFile('./tokens.json', JSON.stringify(newTokenData, null, 4), 'UTF-8')
- },
- tokenData
- );
- const chatClient = new ChatClient({ authProvider, channels: ['sodapoppin', 'dexterous_alloy', 'ashunera'] });
- await chatClient.connect();
- chatClient.onMessage((channel, user, message) => {
- if (message === ';test') {
- chatClient.say(channel, 'Test successful');
- }});
- }
- main();
Advertisement
Add Comment
Please, Sign In to add comment