namespace App\Console\Commands;
-use App\Models\Channel;
use App\Models\DiscordBotCommand;
use App\Models\Episode;
-use App\Models\EpisodeCrew;
use App\Models\EpisodePlayer;
use App\Models\Event;
-use App\Models\Organization;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Console\Command;
return 0;
}
- private function syncEvent(Event $event) {
+ private function syncEvent(Event $event): void {
$hthHandle = substr($event->external_schedule, 4);
$parts = explode('/', $hthHandle);
$hthSeries = $parts[0];
$hthEvent = $parts[1];
- $this->line('series: "'.$hthSeries.'", evnet: "'.$hthEvent.'"');
- $hthSchedule = HTTP::post('https://hth.zeldaspeedruns.com/api/v1/graphql', [
+ $this->line('series: "'.$hthSeries.'", event: "'.$hthEvent.'"');
+ $hthSchedule = Http::withHeaders([
+ 'X-API-Key', config('hth.api_key')
+ ])->post('https://hth.zeldaspeedruns.com/api/v1/graphql', [
'operation_name' => 'my_schedule',
'variables' => [
'my_series' => $hthSeries,
}
}
- private function syncSchedule(Event $event, $hthEntry) {
+ private function syncSchedule(Event $event, $hthEntry): void {
$ext_id = 'hth:'.$hthEntry['id'];
$episode = Episode::firstWhere('ext_id', '=', $ext_id);
if (!$hthEntry['start']) {
}
}
- private function purgePlayers(Episode $episode, $hthEntry) {
+ private function purgePlayers(Episode $episode, $hthEntry): void {
$ext_ids = [];
foreach ($hthEntry['teams'] as $hthTeam) {
foreach ($hthTeam['members'] as $hthPlayer) {
$episode->players()->whereNotIn('ext_id', $ext_ids)->delete();
}
- private function syncPlayer(Episode $episode, $hthTeam, $hthPlayer) {
+ private function syncPlayer(Episode $episode, $hthTeam, $hthPlayer): void {
$ext_id = 'hth:'.$hthPlayer['user']['id'];
$player = $episode->players()->firstWhere('ext_id', '=', $ext_id);
if (!$player) {
$player->save();
}
- private function getUserByHTHPlayer($player) {
+ private function getUserByHTHPlayer($player): User|null {
if (!empty($player['user']['discordId'])) {
$user = User::find($player['user']['discordId']);
if ($user) {