2023-09-28 16:46:39 -07:00
|
|
|
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)]
|
2025-06-17 16:49:58 -04:00
|
|
|
public sealed class RoleUnbanCommand : LocalizedCommands
|
2022-02-21 21:00:55 -08:00
|
|
|
{
|
2025-06-17 16:49:58 -04:00
|
|
|
[Dependency] private readonly IBanManager _banManager = default!;
|
2022-02-21 21:00:55 -08:00
|
|
|
|
2025-06-17 16:49:58 -04: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))
|
|
|
|
|
{
|
2025-06-17 16:49:58 -04:00
|
|
|
shell.WriteLine(Loc.GetString($"cmd-roleunban-unable-to-parse-id", ("id", args[0]), ("help", Help)));
|
2022-02-21 21:00:55 -08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-17 16:49:58 -04:00
|
|
|
var response = await _banManager.PardonRoleBan(banId, shell.Player?.UserId, DateTimeOffset.Now);
|
2023-09-28 16:46:39 -07:00
|
|
|
shell.WriteLine(response);
|
2022-02-21 21:00:55 -08:00
|
|
|
}
|
2022-06-24 04:14:47 -07:00
|
|
|
|
2025-06-17 16:49:58 -04:00
|
|
|
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
2022-06-24 04:14:47 -07:00
|
|
|
{
|
|
|
|
|
// 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
|
|
|
}
|