X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FDiscordBotCommands%2FSyncUserCommand.php;h=520565ce9ffa810448cc6bb916789febbdb40ec7;hb=35dca1d496a5298daad2fc5f926a9fe400f68dce;hp=b9ba6d362f7efbaefa27448ec16c2da92d47abb3;hpb=9bbd52a3b52020f57124e29c22982c6f2d5b1571;p=alttp.git diff --git a/app/DiscordBotCommands/SyncUserCommand.php b/app/DiscordBotCommands/SyncUserCommand.php index b9ba6d3..520565c 100644 --- a/app/DiscordBotCommands/SyncUserCommand.php +++ b/app/DiscordBotCommands/SyncUserCommand.php @@ -30,16 +30,18 @@ class SyncUserCommand extends BaseCommand { } $user->avatar = $discordUser->avatarhash ?: null; - if ($user->avatar) { + $media = Storage::disk('media'); + if ($user->avatar && $media->missing('avatar/'.$user->id.'/'.$user->avatar.'.png')) { try { $url = $discordUser->getAvatarAttribute('png'); $content = Http::get($url)->body(); - $media = Storage::disk('media'); $media->makeDirectory('avatar/'.$user->id); - $media->put('avatar/'.$user->id.'/'.$discordUser->avatarhash.'.png', $content); + $media->put('avatar/'.$user->id.'/'.$user->avatar.'.png', $content); $user->avatar_cached = now(); } catch (\Exception $e) { } + } else { + $user->avatar_cached = now(); } $user->save(); });