$ttl) { $ch = curl_init('https://api.lanyard.rest/v1/users/' . DISCORD_ID); curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 4]); $res = curl_exec($ch); curl_close($ch); if ($res) { @mkdir(DATA_DIR, 0755, true); file_put_contents($cacheFile, $res); } } $data = json_decode(@file_get_contents($cacheFile), true)['data'] ?? null; $status = $data['discord_status'] ?? 'offline'; $spotify = ($data['listening_to_spotify'] ?? false) ? $data['spotify'] : null; $user = $data['discord_user'] ?? []; $did = $user['id'] ?? DISCORD_ID; $name = $user['global_name'] ?? $user['username'] ?? ''; $avatarHash = $user['avatar'] ?? null; $avatar = $avatarHash ? "https://cdn.discordapp.com/avatars/$did/$avatarHash." . (str_starts_with($avatarHash, 'a_') ? 'gif' : 'png') . '?size=128' : 'https://cdn.discordapp.com/embed/avatars/0.png'; $bannerHash = $user['banner'] ?? null; $banner = $bannerHash ? "https://cdn.discordapp.com/banners/$did/$bannerHash." . (str_starts_with($bannerHash, 'a_') ? 'gif' : 'png') . '?size=480' : null; ?>