aboutsummaryrefslogtreecommitdiff
path: root/app/View/Components/DiscordStatus.php
diff options
context:
space:
mode:
authorfloppydiskette <floppydisk@hyprcat.net>2024-08-31 00:47:01 +0100
committerfloppydiskette <floppydisk@hyprcat.net>2024-08-31 00:47:01 +0100
commita715ae58afa15a98006e2271522bef5a00ca071f (patch)
tree5e64ac5ac9e30fd14b96f8e88d3f449fda223ac1 /app/View/Components/DiscordStatus.php
parent97d8f4447d0839d3f251a7dfc2f5f123c36c4d5e (diff)
Handle any errors if unable to get presence or weather data
Diffstat (limited to 'app/View/Components/DiscordStatus.php')
-rw-r--r--app/View/Components/DiscordStatus.php4
1 files changed, 3 insertions, 1 deletions
diff --git a/app/View/Components/DiscordStatus.php b/app/View/Components/DiscordStatus.php
index fac06ae..3ad3a3b 100644
--- a/app/View/Components/DiscordStatus.php
+++ b/app/View/Components/DiscordStatus.php
@@ -31,13 +31,15 @@ class DiscordStatus extends Component
$response = Http::get('https://api.lanyard.rest/v1/users/' . Config::get('services.lanyard.user_id'));
$data = $response->json();
+ if (!isset($data["data"])) return null;
$presence = $data["data"];
Cache::put('discord_presence', $presence, now()->addSeconds(60));
return $presence;
}
- public function getOnlineStatus(): array {
+ public function getOnlineStatus(): ?array {
$presence = $this->getDiscordPresence();
+ if ($presence == null) return null;
return match ($presence["discord_status"]) {
"online", "dnd" => [
"text" => "online",