Advertisement
Guest User

Untitled

a guest
Mar 19th, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. const tmi = require('tmi.js');
  2. const https = require('https');
  3. var client = new tmi.client({
  4. connection: {
  5. cluster: 'aws',
  6. reconnect: true
  7. },
  8. identity: {
  9. username: 'fyllebot',
  10. password: 'oauth:p46cdt86ufuxuto2crss9qj9bggvg2'
  11. },
  12. channels: ['salpsan90']
  13. });
  14.  
  15. client.connect();
  16.  
  17. client.on('chat', (channel, user, message, self) => {
  18. if (message === '!rank') {
  19. https.get('https://euw1.api.riotgames.com/lol/league/v3/positions/by-summoner/19496157?api_key=RGAPI-149ef877-9f97-4c98-ab26-bb738cea5bb9', (res) => {
  20. res.setEncoding('utf8');
  21. let body = '';
  22. res.on('data', data => {
  23. body += data;
  24. });
  25. res.on('end', () => {
  26. body = JSON.parse(body);
  27. const flex = body.find(ch => ch.queueType === 'RANKED_FLEX_SR'),
  28. solo = body.find(ch => ch.queueType === 'RANKED_SOLO_5x5');
  29.  
  30. client.action('salpsan90', 'Solo rank:' + solo.tier + ' ' + solo.rank + '(' + solo.leaguePoints + 'lp) , flex rank: ' + flex.tier + ' ' + flex.rank + '(' + flex.leaguePoints + 'lp)');
  31. });
  32. });
  33. } else {
  34. console.log(message);
  35. }
  36. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement