CatStation/Content.Server/Afk/IsAfkCommand.cs
Pieter-Jan Briers 5168b5f3d4
IoC source gen compatibility (#43863)
* IoC source gen compatibility

Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter.

* Missed a spot
2026-05-09 03:29:58 +00:00

45 lines
1.4 KiB
C#

using Content.Server.Administration;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.Afk
{
[AdminCommand(AdminFlags.Admin)]
public sealed partial class IsAfkCommand : LocalizedCommands
{
[Dependency] private IAfkManager _afkManager = default!;
[Dependency] private IPlayerManager _players = default!;
public override string Command => "isafk";
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length == 0)
{
shell.WriteError(Loc.GetString($"shell-need-exactly-one-argument"));
return;
}
if (!_players.TryGetSessionByUsername(args[0], out var player))
{
shell.WriteError(Loc.GetString($"shell-target-player-does-not-exist"));
return;
}
shell.WriteLine(Loc.GetString(_afkManager.IsAfk(player) ? "cmd-isafk-true" : "cmd-isafk-false"));
}
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
if (args.Length == 1)
{
return CompletionResult.FromHintOptions(
CompletionHelper.SessionNames(players: _players),
"<playerName>");
}
return CompletionResult.Empty;
}
}
}