diff --git a/Commands/Ping.cs b/Commands/Ping.cs index 22155a3..905de7d 100644 --- a/Commands/Ping.cs +++ b/Commands/Ping.cs @@ -18,6 +18,7 @@ await ctx.EditResponseAsync(new DiscordWebhookBuilder().WithContent( $"Pong!\n" + $"Websocket ping: `{websocketPing}ms`\n" + $"Interaction latency: `{interactionLatency}ms`\n" - + $"Database ping: {(double.IsNaN(dbPing) ? "Unreachable!" : $"`{dbPing}ms`")}")); + + $"Database ping: {(double.IsNaN(dbPing) ? "Unreachable!" : $"`{dbPing}ms`")}\n" + + $"Uptime Kuma heartbeat status: `{Program.LastUptimeKumaHeartbeatStatus}`")); } } \ No newline at end of file diff --git a/Events/HeartbeatEvent.cs b/Events/HeartbeatEvent.cs index 8f5d31b..b62bc94 100644 --- a/Events/HeartbeatEvent.cs +++ b/Events/HeartbeatEvent.cs @@ -13,10 +13,12 @@ public static async Task Heartbeated(DiscordClient client, HeartbeatEventArgs e) Program.Discord.Logger.LogDebug(Program.BotEventId, "Successfully sent Uptime Kuma heartbeat with ping {ping}ms", e.Ping); else Program.Discord.Logger.LogWarning(Program.BotEventId, "Uptime Kuma heartbeat failed with status code {statusCode}", heartbeatResponse.StatusCode); + Program.LastUptimeKumaHeartbeatStatus = heartbeatResponse.StatusCode.ToString(); } catch (Exception ex) { Program.Discord.Logger.LogWarning(Program.BotEventId, "Uptime Kuma heartbeat failed: {exType}: {exMessage}\n{stackTrace}", ex.GetType(), ex.Message, ex.StackTrace); + Program.LastUptimeKumaHeartbeatStatus = "exception thrown"; } } } \ No newline at end of file diff --git a/Program.cs b/Program.cs index ec240d7..31ce76e 100644 --- a/Program.cs +++ b/Program.cs @@ -1,4 +1,5 @@ -using System.Threading; +using System.Net; +using System.Threading; namespace MechanicalMilkshake; @@ -26,6 +27,7 @@ public class Program public static readonly IDatabase Db = Redis.GetDatabase(); public static bool RedisExceptionsSuppressed; public static readonly MessageCache MessageCache = new(); + public static string LastUptimeKumaHeartbeatStatus = "N/A"; public static readonly Dictionary UserFlagEmoji = new() {