fix embed queue
This commit is contained in:
parent
ded4f4db26
commit
8d4a7b1729
13 changed files with 188 additions and 32 deletions
|
|
@ -1,10 +1,16 @@
|
|||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using Catalogger.Backend.Cache;
|
||||
using Catalogger.Backend.Database;
|
||||
using Catalogger.Backend.Extensions;
|
||||
using Humanizer;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NodaTime;
|
||||
using Remora.Commands.Attributes;
|
||||
using Remora.Commands.Groups;
|
||||
using Remora.Discord.API.Abstractions.Rest;
|
||||
using Remora.Discord.Commands.Feedback.Services;
|
||||
using Remora.Discord.Extensions.Embeds;
|
||||
using Remora.Discord.Gateway;
|
||||
using Remora.Results;
|
||||
using IResult = Remora.Results.IResult;
|
||||
|
|
@ -14,7 +20,10 @@ namespace Catalogger.Backend.Bot.Commands;
|
|||
[Group("catalogger")]
|
||||
public class MetaCommands(
|
||||
IClock clock,
|
||||
DatabaseContext db,
|
||||
DiscordGatewayClient client,
|
||||
GuildCacheService guildCache,
|
||||
ChannelCacheService channelCache,
|
||||
IFeedbackService feedbackService,
|
||||
IDiscordRestChannelAPI channelApi) : CommandGroup
|
||||
{
|
||||
|
|
@ -26,6 +35,24 @@ public class MetaCommands(
|
|||
var msg = await feedbackService.SendContextualAsync("...").GetOrThrow();
|
||||
var elapsed = clock.GetCurrentInstant() - t1;
|
||||
|
||||
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("")
|
||||
.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("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");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue