Skip to content

Commit 2f30fe3

Browse files
authored
adminnotes command cleanup (space-wizards#36086)
localize adminnotes command, autocomplete
1 parent 462519b commit 2f30fe3

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

Content.Server/Administration/Commands/OpenAdminNotesCommand.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
using Content.Server.Administration.Notes;
1+
using System.Linq;
2+
using Content.Server.Administration.Notes;
23
using Content.Shared.Administration;
4+
using Robust.Server.Player;
35
using Robust.Shared.Console;
46

57
namespace Content.Server.Administration.Commands;
68

79
[AdminCommand(AdminFlags.ViewNotes)]
8-
public sealed class OpenAdminNotesCommand : IConsoleCommand
10+
public sealed class OpenAdminNotesCommand : LocalizedCommands
911
{
1012
public const string CommandName = "adminnotes";
1113

12-
public string Command => CommandName;
13-
public string Description => "Opens the admin notes panel.";
14-
public string Help => $"Usage: {Command} <notedPlayerUserId OR notedPlayerUsername>";
14+
public override string Command => CommandName;
1515

16-
public async void Execute(IConsoleShell shell, string argStr, string[] args)
16+
public override async void Execute(IConsoleShell shell, string argStr, string[] args)
1717
{
1818
if (shell.Player is not { } player)
1919
{
@@ -33,17 +33,27 @@ public async void Execute(IConsoleShell shell, string argStr, string[] args)
3333

3434
if (dbGuid == null)
3535
{
36-
shell.WriteError($"Unable to find {args[0]} netuserid");
36+
shell.WriteError(Loc.GetString("cmd-adminnotes-wrong-target", ("user", args[0])));
3737
return;
3838
}
3939

4040
notedPlayer = dbGuid.UserId;
4141
break;
4242
default:
43-
shell.WriteError($"Invalid arguments.\n{Help}");
43+
shell.WriteError(Loc.GetString("cmd-adminnotes-args-error"));
4444
return;
4545
}
4646

4747
await IoCManager.Resolve<IAdminNotesManager>().OpenEui(player, notedPlayer);
4848
}
49+
50+
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
51+
{
52+
if (args.Length != 1)
53+
return CompletionResult.Empty;
54+
55+
var playerMgr = IoCManager.Resolve<IPlayerManager>();
56+
var options = playerMgr.Sessions.Select(c => c.Name).OrderBy(c => c).ToArray();
57+
return CompletionResult.FromHintOptions(options, Loc.GetString("cmd-adminnotes-hint"));
58+
}
4959
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cmd-adminnotes-desc = Opens the admin notes panel of target player.
2+
cmd-adminnotes-help = Usage: adminnotes <UserId OR Username>
3+
4+
cmd-adminnotes-wrong-target = Unable to find user '{$user}'.
5+
cmd-adminnotes-args-error = Invalid arguments.
6+
Usage: adminnotes <UserId OR Username>
7+
8+
cmd-adminnotes-hint = UserId OR Username

0 commit comments

Comments
 (0)