From 110edd34b46c17bd3257b60eb1acf5861f9de21d Mon Sep 17 00:00:00 2001 From: sam Date: Tue, 13 Aug 2024 17:02:11 +0200 Subject: [PATCH] add runtime info to ping command --- Catalogger.Backend/Bot/Commands/MetaCommands.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Catalogger.Backend/Bot/Commands/MetaCommands.cs b/Catalogger.Backend/Bot/Commands/MetaCommands.cs index bd8d055..4a35132 100644 --- a/Catalogger.Backend/Bot/Commands/MetaCommands.cs +++ b/Catalogger.Backend/Bot/Commands/MetaCommands.cs @@ -1,5 +1,6 @@ using System.ComponentModel; using System.Diagnostics; +using System.Runtime.InteropServices; using Catalogger.Backend.Cache; using Catalogger.Backend.Database; using Catalogger.Backend.Extensions; @@ -8,6 +9,7 @@ using Microsoft.EntityFrameworkCore; using NodaTime; using Remora.Commands.Attributes; using Remora.Commands.Groups; +using Remora.Discord.API.Abstractions.Objects; using Remora.Discord.API.Abstractions.Rest; using Remora.Discord.Commands.Feedback.Services; using Remora.Discord.Extensions.Embeds; @@ -38,22 +40,21 @@ public class MetaCommands( var messageCount = await db.Messages.CountAsync(); var process = Process.GetCurrentProcess(); var memoryUsage = process.WorkingSet64; - var virtualMemory = process.VirtualMemorySize64; var embed = new EmbedBuilder() .WithColour(DiscordUtils.Purple) - .WithFooter("") + .WithFooter($"{RuntimeInformation.FrameworkDescription} on {RuntimeInformation.RuntimeIdentifier}") .WithCurrentTimestamp(); embed.AddField("Ping", $"Gateway: {client.Latency.Humanize()}\nAPI: {elapsed.ToTimeSpan().Humanize()}", inline: true); - embed.AddField("Memory usage", $"{memoryUsage.Bytes().Humanize()} / {virtualMemory.Bytes().Humanize()}", - inline: true); + embed.AddField("Memory usage", memoryUsage.Bytes().Humanize(), inline: true); embed.AddField("Numbers", $"{messageCount:N0} messages from {guildCache.Size:N0} servers\nCached {channelCache.Size:N0} channels", inline: false); - return (Result)await channelApi.EditMessageAsync(msg.ChannelID, msg.ID, - content: $"Pong! API: {elapsed.TotalMilliseconds:N0}ms | Gateway: {client.Latency.TotalMilliseconds:N0}ms"); + List embeds = [embed.Build().GetOrThrow()]; + + return (Result)await channelApi.EditMessageAsync(msg.ChannelID, msg.ID, content: "", embeds: embeds); } } \ No newline at end of file