@@ -5,24 +5,24 @@ const POLL_INTERVAL = 30*1000;
5
5
function Followers ( nodecg ) {
6
6
this . nodecg = nodecg ;
7
7
this . twitch = nodecg . extensions [ 'lfg-twitchapi' ] ;
8
- this . latestFollower = nodecg . Replicant ( " latestFollower" , { defaultValue : null , persistent : true } ) ;
8
+ this . latestFollower = nodecg . Replicant ( ' latestFollower' , { defaultValue : null , persistent : true } ) ;
9
9
10
10
this . _scheduleFollowers ( ) ;
11
11
}
12
12
13
13
Followers . prototype . _scheduleFollowers = function ( ) {
14
- this . nodecg . log . debug ( " Polling for TwitchTV Followers." ) ;
14
+ this . nodecg . log . debug ( ' Polling for TwitchTV Followers.' ) ;
15
15
this . twitch . get ( '/channels/{{username}}/follows' , { limit : 50 , direction : 'desc' } ,
16
- function ( err , code , body ) {
16
+ ( err , code , body ) => {
17
17
if ( err ) {
18
18
this . nodecg . log . error ( err ) ;
19
- setTimeout ( function ( ) { this . _scheduleFollowers ( ) } . bind ( this ) , POLL_INTERVAL ) ;
19
+ setTimeout ( ( ) => { this . _scheduleFollowers ( ) ; } , POLL_INTERVAL ) ;
20
20
return ;
21
21
}
22
22
23
23
if ( code != 200 ) {
24
- this . nodecg . log . error ( " Unknown response code: " + code ) ;
25
- setTimeout ( function ( ) { this . _scheduleFollowers ( ) } . bind ( this ) , POLL_INTERVAL ) ;
24
+ this . nodecg . log . error ( ' Unknown response code: ' + code ) ;
25
+ setTimeout ( ( ) => { this . _scheduleFollowers ( ) ; } , POLL_INTERVAL ) ;
26
26
return ;
27
27
}
28
28
@@ -32,19 +32,19 @@ Followers.prototype._scheduleFollowers = function() {
32
32
}
33
33
34
34
if ( body . follows . length > 0 ) {
35
- this . nodecg . log . debug ( " Discovered " + body . follows . length + " followers." ) ;
35
+ this . nodecg . log . debug ( ' Discovered ' + body . follows . length + ' followers.' ) ;
36
36
this . latestFollower . value = body . follows [ 0 ] ;
37
37
38
- body . follows . reverse ( ) . map ( function ( follower ) {
38
+ body . follows . reverse ( ) . map ( ( follower ) => {
39
39
var parsedTs = Date . parse ( follower . created_at ) ;
40
40
if ( parsedTs > lastFollowerTs ) {
41
41
this . nodecg . sendMessage ( 'follower' , follower ) ;
42
42
}
43
- } . bind ( this ) ) ;
43
+ } ) ;
44
44
}
45
45
46
- setTimeout ( function ( ) { this . _scheduleFollowers ( ) } . bind ( this ) , POLL_INTERVAL ) ;
47
- } . bind ( this )
46
+ setTimeout ( ( ) => { this . _scheduleFollowers ( ) ; } , POLL_INTERVAL ) ;
47
+ }
48
48
) ;
49
49
} ;
50
50
0 commit comments