28 lines
1.0 KiB
C#
28 lines
1.0 KiB
C#
using SkyBot.Helpers;
|
|
using SkyBot.Models;
|
|
|
|
namespace SkyBot.Commands
|
|
{
|
|
public class Uptime : ICommand
|
|
{
|
|
public string Name => "uptime";
|
|
public string[] Aliases => [];
|
|
public string Description => "Displays the uptime of the bot";
|
|
public string Category => "Info";
|
|
public string Usage => "uptime";
|
|
public string[] SubCommands => [];
|
|
|
|
public async Task Execute(CommandContext ctx)
|
|
{
|
|
TimeSpan uptime = DateTime.UtcNow - Program.StartTime;
|
|
string formatted = uptime.TotalDays >= 1
|
|
? $"{(int)uptime.TotalDays}d {uptime.Hours}h {uptime.Minutes}m {uptime.Seconds}s"
|
|
: uptime.TotalHours >= 1
|
|
? $"{uptime.Hours}h {uptime.Minutes}m {uptime.Seconds}s"
|
|
: uptime.TotalMinutes >= 1
|
|
? $"{uptime.Minutes}m {uptime.Seconds}s"
|
|
: $"{uptime.Seconds}s";
|
|
await MessageHelper.ReplyAsync(ctx, $"⏱️ SkyBot Uptime: {formatted}");
|
|
}
|
|
}
|
|
} |