using System.ComponentModel; using Catalogger.Backend.Extensions; 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.Gateway; using Remora.Results; using IResult = Remora.Results.IResult; namespace Catalogger.Backend.Bot.Commands; [Group("catalogger")] public class MetaCommands( IClock clock, DiscordGatewayClient client, IFeedbackService feedbackService, IDiscordRestChannelAPI channelApi) : CommandGroup { [Command("ping")] [Description("Ping pong! See the bot's latency")] public async Task PingAsync() { var t1 = clock.GetCurrentInstant(); var msg = await feedbackService.SendContextualAsync("...").GetOrThrow(); var elapsed = clock.GetCurrentInstant() - t1; return (Result)await channelApi.EditMessageAsync(msg.ChannelID, msg.ID, content: $"Pong! API: {elapsed.TotalMilliseconds:N0}ms | Gateway: {client.Latency.TotalMilliseconds:N0}ms"); } }