add runtime info to ping command
This commit is contained in:
parent
8d4a7b1729
commit
110edd34b4
1 changed files with 7 additions and 6 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using Catalogger.Backend.Cache;
|
using Catalogger.Backend.Cache;
|
||||||
using Catalogger.Backend.Database;
|
using Catalogger.Backend.Database;
|
||||||
using Catalogger.Backend.Extensions;
|
using Catalogger.Backend.Extensions;
|
||||||
|
|
@ -8,6 +9,7 @@ using Microsoft.EntityFrameworkCore;
|
||||||
using NodaTime;
|
using NodaTime;
|
||||||
using Remora.Commands.Attributes;
|
using Remora.Commands.Attributes;
|
||||||
using Remora.Commands.Groups;
|
using Remora.Commands.Groups;
|
||||||
|
using Remora.Discord.API.Abstractions.Objects;
|
||||||
using Remora.Discord.API.Abstractions.Rest;
|
using Remora.Discord.API.Abstractions.Rest;
|
||||||
using Remora.Discord.Commands.Feedback.Services;
|
using Remora.Discord.Commands.Feedback.Services;
|
||||||
using Remora.Discord.Extensions.Embeds;
|
using Remora.Discord.Extensions.Embeds;
|
||||||
|
|
@ -38,22 +40,21 @@ public class MetaCommands(
|
||||||
var messageCount = await db.Messages.CountAsync();
|
var messageCount = await db.Messages.CountAsync();
|
||||||
var process = Process.GetCurrentProcess();
|
var process = Process.GetCurrentProcess();
|
||||||
var memoryUsage = process.WorkingSet64;
|
var memoryUsage = process.WorkingSet64;
|
||||||
var virtualMemory = process.VirtualMemorySize64;
|
|
||||||
|
|
||||||
var embed = new EmbedBuilder()
|
var embed = new EmbedBuilder()
|
||||||
.WithColour(DiscordUtils.Purple)
|
.WithColour(DiscordUtils.Purple)
|
||||||
.WithFooter("")
|
.WithFooter($"{RuntimeInformation.FrameworkDescription} on {RuntimeInformation.RuntimeIdentifier}")
|
||||||
.WithCurrentTimestamp();
|
.WithCurrentTimestamp();
|
||||||
embed.AddField("Ping", $"Gateway: {client.Latency.Humanize()}\nAPI: {elapsed.ToTimeSpan().Humanize()}",
|
embed.AddField("Ping", $"Gateway: {client.Latency.Humanize()}\nAPI: {elapsed.ToTimeSpan().Humanize()}",
|
||||||
inline: true);
|
inline: true);
|
||||||
embed.AddField("Memory usage", $"{memoryUsage.Bytes().Humanize()} / {virtualMemory.Bytes().Humanize()}",
|
embed.AddField("Memory usage", memoryUsage.Bytes().Humanize(), inline: true);
|
||||||
inline: true);
|
|
||||||
|
|
||||||
embed.AddField("Numbers",
|
embed.AddField("Numbers",
|
||||||
$"{messageCount:N0} messages from {guildCache.Size:N0} servers\nCached {channelCache.Size:N0} channels",
|
$"{messageCount:N0} messages from {guildCache.Size:N0} servers\nCached {channelCache.Size:N0} channels",
|
||||||
inline: false);
|
inline: false);
|
||||||
|
|
||||||
return (Result)await channelApi.EditMessageAsync(msg.ChannelID, msg.ID,
|
List<IEmbed> embeds = [embed.Build().GetOrThrow()];
|
||||||
content: $"Pong! API: {elapsed.TotalMilliseconds:N0}ms | Gateway: {client.Latency.TotalMilliseconds:N0}ms");
|
|
||||||
|
return (Result)await channelApi.EditMessageAsync(msg.ChannelID, msg.ID, content: "", embeds: embeds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue