Files
crystall-punk-14/Content.Server/Administration/Commands/RoleUnbanCommand.cs

42 lines
1.2 KiB
C#
Raw Normal View History

using Content.Server.Administration.Managers;
2022-02-21 21:00:55 -08:00
using Content.Shared.Administration;
using Robust.Shared.Console;
namespace Content.Server.Administration.Commands;
[AdminCommand(AdminFlags.Ban)]
public sealed class RoleUnbanCommand : LocalizedCommands
2022-02-21 21:00:55 -08:00
{
[Dependency] private readonly IBanManager _banManager = default!;
2022-02-21 21:00:55 -08:00
public override string Command => "roleunban";
public override async void Execute(IConsoleShell shell, string argStr, string[] args)
2022-02-21 21:00:55 -08:00
{
if (args.Length != 1)
{
shell.WriteLine(Help);
return;
}
if (!int.TryParse(args[0], out var banId))
{
shell.WriteLine(Loc.GetString($"cmd-roleunban-unable-to-parse-id", ("id", args[0]), ("help", Help)));
2022-02-21 21:00:55 -08:00
return;
}
var response = await _banManager.PardonRoleBan(banId, shell.Player?.UserId, DateTimeOffset.Now);
shell.WriteLine(response);
2022-02-21 21:00:55 -08:00
}
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
// Can't think of good way to do hint options for this
return args.Length switch
{
1 => CompletionResult.FromHint(Loc.GetString("cmd-roleunban-hint-1")),
_ => CompletionResult.Empty
};
}
2022-02-21 21:00:55 -08:00
}