]> git.localhorst.tv Git - alttp.git/blobdiff - app/Console/Commands/TwitchChannelInfo.php
track twitch token expiration
[alttp.git] / app / Console / Commands / TwitchChannelInfo.php
index 6a3261ca8a9eb1b72bb6e4a3dbd7d9768b88541e..7b373c8c94ed54fe611280078158799e35002775 100644 (file)
@@ -37,6 +37,10 @@ class TwitchChannelInfo extends Command {
                        $this->line('please acquire a token for localhorsttv first');
                        return 1;
                }
+               if ($this->token->hasExpired()) {
+                       $this->line('access token has expired, refreshing');
+                       $this->token->refresh();
+               }
                $channels = Channel::where('twitch_chat', '!=', '')->where('twitch_id', '=', '')->get();
                foreach ($channels as $channel) {
                        try {
@@ -52,7 +56,8 @@ class TwitchChannelInfo extends Command {
                        ->where(function($query) {
                                $query->where('join', true);
                                $query->orWhere('chat', true);
-                       })->chunk(100, function ($channels) {
+                       })
+                       ->chunk(100, function ($channels) {
                                $this->updateChannelInfos($channels);
                        });
                return Command::SUCCESS;