-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUptimeCommandHandler.cs
More file actions
23 lines (20 loc) · 924 Bytes
/
Copy pathUptimeCommandHandler.cs
File metadata and controls
23 lines (20 loc) · 924 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using RustPlusBot.Abstractions.Formatting;
using RustPlusBot.Features.Commands.Dispatching;
using RustPlusBot.Features.Commands.Hosting;
using RustPlusBot.Localization;
namespace RustPlusBot.Features.Commands.Handlers;
/// <summary>!uptime — reports how long the bot process has been running.</summary>
/// <param name="uptime">The process-uptime baseline.</param>
/// <param name="localizer">The reply localizer.</param>
internal sealed class UptimeCommandHandler(BotUptime uptime, ILocalizer localizer) : ICommandHandler
{
/// <inheritdoc />
public string Name => "uptime";
/// <inheritdoc />
public Task<string?> ExecuteAsync(CommandContext context, CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(context);
return Task.FromResult<string?>(
localizer.Get("command.uptime.ok", context.Culture, DurationFormat.Compact(uptime.Elapsed)));
}
}