init
This commit is contained in:
commit
ded4f4db26
43 changed files with 2052 additions and 0 deletions
32
Catalogger.Backend/Bot/Commands/MetaCommands.cs
Normal file
32
Catalogger.Backend/Bot/Commands/MetaCommands.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
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<IResult> 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");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue