namespace App\Console\Commands;
use App\Models\Channel;
+use App\Models\DiscordBotCommand;
use App\Models\Episode;
use App\Models\EpisodePlayer;
use App\Models\Event;
$user = $this->getUserBySGPlayer($sgPlayer);
if ($user) {
$player->user()->associate($user);
+ if (empty($user->stream_link)) {
+ if (!empty($sgPlayer['publicStream'])) {
+ $user->stream_link = 'https://twitch.tv/'.strtolower($sgPlayer['publicStream']);
+ $user->save();
+ } else if (!empty($sgPlayer['streamingFrom'])) {
+ $user->stream_link = 'https://twitch.tv/'.strtolower($sgPlayer['streamingFrom']);
+ $user->save();
+ }
+ }
} else {
$player->user()->disassociate();
}
if (!empty($player['discordId'])) {
$user = User::find($player['discordId']);
if ($user) return $user;
+ DiscordBotCommand::syncUser($player['discordId']);
}
if (!empty($player['discordTag'])) {
$tag = explode('#', $player['discordTag']);
$cmd->save();
}
+ public static function syncUser($user_id) {
+ $cmd = new DiscordBotCommand();
+ $cmd->command = 'sync-user';
+ $cmd->parameters = [
+ 'user' => $user_id,
+ ];
+ $cmd->status = 'pending';
+ $cmd->save();
+ }
+
public function tournament() {
return $this->belongsTo(Tournament::class);
}