cs-codex-dist-tests/Tools/BiblioTech/Commands/DeploymentsCommand.cs

39 lines
1.1 KiB
C#
Raw Normal View History

2023-10-23 08:19:52 +00:00
using CodexPlugin;
using Discord.WebSocket;
2023-10-22 08:38:46 +00:00
namespace BiblioTech.Commands
{
public class DeploymentsCommand : BaseCommand
{
private readonly DeploymentsFilesMonitor monitor;
public DeploymentsCommand(DeploymentsFilesMonitor monitor)
{
this.monitor = monitor;
}
public override string Name => "deployments";
public override string StartingMessage => "Fetching deployments information...";
2023-10-22 09:10:45 +00:00
public override string Description => "Lists active TestNet deployments";
protected override async Task Invoke(SocketSlashCommand command)
{
var deployments = monitor.GetDeployments();
if (!deployments.Any())
{
await command.FollowupAsync("No deployments available.");
return;
}
2023-10-23 08:19:52 +00:00
await command.FollowupAsync($"Deployments: {string.Join(", ", deployments.Select(FormatDeployment))}");
}
private string FormatDeployment(CodexDeployment deployment)
{
var m = deployment.Metadata;
return $"{m.Name} ({m.StartUtc.ToString("o")})";
}
}
}