diff --git a/Events/HeartbeatEvent.cs b/Events/HeartbeatEvent.cs index 7613dcdd..8355e644 100644 --- a/Events/HeartbeatEvent.cs +++ b/Events/HeartbeatEvent.cs @@ -9,7 +9,16 @@ public static async Task OnHeartbeat(IGatewayClient client) Program.discord.Logger.LogDebug("Heartbeat ping: {ping}", client.Ping.TotalMicroseconds); if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("UPTIME_KUMA_PUSH_URL")) && client.IsConnected) { - var response = await Program.httpClient.GetAsync(Environment.GetEnvironmentVariable("UPTIME_KUMA_PUSH_URL") + client.Ping.TotalMicroseconds); + HttpResponseMessage response; + try + { + response = await Program.httpClient.GetAsync(Environment.GetEnvironmentVariable("UPTIME_KUMA_PUSH_URL") + client.Ping.TotalMicroseconds); + } + catch (Exception ex) + { + Program.discord.Logger.LogError(ex, "Uptime Kuma push failed during heartbeat event!"); + return; + } if (response.StatusCode == HttpStatusCode.OK) { Program.discord.Logger.LogDebug("Heartbeat ping succeeded."); diff --git a/Events/ReadyEvent.cs b/Events/ReadyEvent.cs index b877c7e6..96316572 100644 --- a/Events/ReadyEvent.cs +++ b/Events/ReadyEvent.cs @@ -140,7 +140,16 @@ public static async Task OnStartup(DiscordClient client) if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("UPTIME_KUMA_PUSH_URL"))) { - var response = await Program.httpClient.GetAsync(Environment.GetEnvironmentVariable("UPTIME_KUMA_PUSH_URL")); + HttpResponseMessage response; + try + { + response = await Program.httpClient.GetAsync(Environment.GetEnvironmentVariable("UPTIME_KUMA_PUSH_URL")); + } + catch (Exception ex) + { + discord.Logger.LogError(ex, "Uptime Kuma push failed during startup!"); + return; + } if (response.StatusCode == HttpStatusCode.OK) { discord.Logger.LogDebug("Heartbeat ping succeeded.");