Roleban completions (#9114)
* Roleban completions * helpers * eat my peenor dumb robot
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
using Content.Server.Administration.Managers;
|
||||
using System.Linq;
|
||||
using Content.Server.Administration.Managers;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Roles;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Serilog;
|
||||
|
||||
namespace Content.Server.Administration.Commands;
|
||||
|
||||
@@ -8,8 +13,8 @@ namespace Content.Server.Administration.Commands;
|
||||
public sealed class RoleBanCommand : IConsoleCommand
|
||||
{
|
||||
public string Command => "roleban";
|
||||
public string Description => "Bans a player from a role";
|
||||
public string Help => $"Usage: {Command} <name or user ID> <job> <reason> [duration in minutes, leave out or 0 for permanent ban]";
|
||||
public string Description => Loc.GetString("cmd-roleban-desc");
|
||||
public string Help => Loc.GetString("cmd-roleban-help");
|
||||
|
||||
public async void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
@@ -46,4 +51,25 @@ public sealed class RoleBanCommand : IConsoleCommand
|
||||
|
||||
IoCManager.Resolve<RoleBanManager>().CreateJobBan(shell, target, job, reason, minutes);
|
||||
}
|
||||
|
||||
public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
||||
{
|
||||
var durOpts = new CompletionOption[]
|
||||
{
|
||||
new("0", Loc.GetString("cmd-roleban-hint-duration-1")),
|
||||
new("1440", Loc.GetString("cmd-roleban-hint-duration-2")),
|
||||
new("10080", Loc.GetString("cmd-roleban-hint-duration-3")),
|
||||
};
|
||||
|
||||
return args.Length switch
|
||||
{
|
||||
1 => CompletionResult.FromHintOptions(CompletionHelper.SessionNames(),
|
||||
Loc.GetString("cmd-roleban-hint-1")),
|
||||
2 => CompletionResult.FromHintOptions(CompletionHelper.PrototypeIDs<JobPrototype>(),
|
||||
Loc.GetString("cmd-roleban-hint-2")),
|
||||
3 => CompletionResult.FromHint(Loc.GetString("cmd-roleban-hint-3")),
|
||||
4 => CompletionResult.FromHintOptions(durOpts, Loc.GetString("cmd-roleban-hint-4")),
|
||||
_ => CompletionResult.Empty
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Content.Server.Database;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Console;
|
||||
|
||||
namespace Content.Server.Administration.Commands;
|
||||
@@ -9,8 +11,8 @@ namespace Content.Server.Administration.Commands;
|
||||
public sealed class RoleBanListCommand : IConsoleCommand
|
||||
{
|
||||
public string Command => "rolebanlist";
|
||||
public string Description => "Lists the user's role bans";
|
||||
public string Help => "Usage: <name or user ID> [include unbanned]";
|
||||
public string Description => Loc.GetString("cmd-rolebanlist-desc");
|
||||
public string Help => Loc.GetString("cmd-rolebanlist-help");
|
||||
|
||||
public async void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
@@ -88,4 +90,16 @@ public sealed class RoleBanListCommand : IConsoleCommand
|
||||
|
||||
shell.WriteLine(bansString.ToString());
|
||||
}
|
||||
|
||||
public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
||||
{
|
||||
return args.Length switch
|
||||
{
|
||||
1 => CompletionResult.FromHintOptions(CompletionHelper.SessionNames(),
|
||||
Loc.GetString("cmd-rolebanlist-hint-1")),
|
||||
2 => CompletionResult.FromHintOptions(CompletionHelper.Booleans,
|
||||
Loc.GetString("cmd-rolebanlist-hint-2")),
|
||||
_ => CompletionResult.Empty
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ namespace Content.Server.Administration.Commands;
|
||||
public sealed class RoleUnbanCommand : IConsoleCommand
|
||||
{
|
||||
public string Command => "roleunban";
|
||||
public string Description => "Pardons a player's role ban";
|
||||
public string Help => $"Usage: {Command} <role ban id>";
|
||||
public string Description => Loc.GetString("cmd-roleunban-desc");
|
||||
public string Help => Loc.GetString("cmd-roleunban-help");
|
||||
|
||||
public async void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
@@ -57,4 +57,14 @@ public sealed class RoleUnbanCommand : IConsoleCommand
|
||||
|
||||
shell.WriteLine($"Pardoned ban with id {banId}");
|
||||
}
|
||||
|
||||
public 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
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
33
Resources/Locale/en-US/job/role-ban-command.ftl
Normal file
33
Resources/Locale/en-US/job/role-ban-command.ftl
Normal file
@@ -0,0 +1,33 @@
|
||||
### Localization for role ban command
|
||||
|
||||
cmd-roleban-desc = Bans a player from a role
|
||||
cmd-roleban-help = Usage: roleban <name or user ID> <job> <reason> [duration in minutes, leave out or 0 for permanent ban]
|
||||
|
||||
## Completion result hints
|
||||
cmd-roleban-hint-1 = <name or user ID>
|
||||
cmd-roleban-hint-2 = <job>
|
||||
cmd-roleban-hint-3 = <reason>
|
||||
cmd-roleban-hint-4 = [duration in minutes, leave out or 0 for permanent ban]
|
||||
|
||||
cmd-roleban-hint-duration-1 = Permanent
|
||||
cmd-roleban-hint-duration-2 = 1 day
|
||||
cmd-roleban-hint-duration-3 = 1 week
|
||||
|
||||
|
||||
### Localization for role unban command
|
||||
|
||||
cmd-roleunban-desc = Pardons a player's role ban
|
||||
cmd-roleunban-help = Usage: roleunban <role ban id>
|
||||
|
||||
## Completion result hints
|
||||
cmd-roleunban-hint-1 = <role ban id>
|
||||
|
||||
|
||||
### Localization for roleban list command
|
||||
|
||||
cmd-rolebanlist-desc = Lists the user's role bans
|
||||
cmd-rolebanlist-help = Usage: <name or user ID> [include unbanned]
|
||||
|
||||
## Completion result hints
|
||||
cmd-rolebanlist-hint-1 = <name or user ID>
|
||||
cmd-rolebanlist-hint-2 = [include unbanned]
|
||||
Reference in New Issue
Block a user