adminnotes command cleanup (#36086)
localize adminnotes command, autocomplete
This commit is contained in:
@@ -1,19 +1,19 @@
|
|||||||
using Content.Server.Administration.Notes;
|
using System.Linq;
|
||||||
|
using Content.Server.Administration.Notes;
|
||||||
using Content.Shared.Administration;
|
using Content.Shared.Administration;
|
||||||
|
using Robust.Server.Player;
|
||||||
using Robust.Shared.Console;
|
using Robust.Shared.Console;
|
||||||
|
|
||||||
namespace Content.Server.Administration.Commands;
|
namespace Content.Server.Administration.Commands;
|
||||||
|
|
||||||
[AdminCommand(AdminFlags.ViewNotes)]
|
[AdminCommand(AdminFlags.ViewNotes)]
|
||||||
public sealed class OpenAdminNotesCommand : IConsoleCommand
|
public sealed class OpenAdminNotesCommand : LocalizedCommands
|
||||||
{
|
{
|
||||||
public const string CommandName = "adminnotes";
|
public const string CommandName = "adminnotes";
|
||||||
|
|
||||||
public string Command => CommandName;
|
public override string Command => CommandName;
|
||||||
public string Description => "Opens the admin notes panel.";
|
|
||||||
public string Help => $"Usage: {Command} <notedPlayerUserId OR notedPlayerUsername>";
|
|
||||||
|
|
||||||
public async void Execute(IConsoleShell shell, string argStr, string[] args)
|
public override async void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||||
{
|
{
|
||||||
if (shell.Player is not { } player)
|
if (shell.Player is not { } player)
|
||||||
{
|
{
|
||||||
@@ -33,17 +33,27 @@ public sealed class OpenAdminNotesCommand : IConsoleCommand
|
|||||||
|
|
||||||
if (dbGuid == null)
|
if (dbGuid == null)
|
||||||
{
|
{
|
||||||
shell.WriteError($"Unable to find {args[0]} netuserid");
|
shell.WriteError(Loc.GetString("cmd-adminnotes-wrong-target", ("user", args[0])));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
notedPlayer = dbGuid.UserId;
|
notedPlayer = dbGuid.UserId;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
shell.WriteError($"Invalid arguments.\n{Help}");
|
shell.WriteError(Loc.GetString("cmd-adminnotes-args-error"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await IoCManager.Resolve<IAdminNotesManager>().OpenEui(player, notedPlayer);
|
await IoCManager.Resolve<IAdminNotesManager>().OpenEui(player, notedPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
||||||
|
{
|
||||||
|
if (args.Length != 1)
|
||||||
|
return CompletionResult.Empty;
|
||||||
|
|
||||||
|
var playerMgr = IoCManager.Resolve<IPlayerManager>();
|
||||||
|
var options = playerMgr.Sessions.Select(c => c.Name).OrderBy(c => c).ToArray();
|
||||||
|
return CompletionResult.FromHintOptions(options, Loc.GetString("cmd-adminnotes-hint"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
cmd-adminnotes-desc = Opens the admin notes panel of target player.
|
||||||
|
cmd-adminnotes-help = Usage: adminnotes <UserId OR Username>
|
||||||
|
|
||||||
|
cmd-adminnotes-wrong-target = Unable to find user '{$user}'.
|
||||||
|
cmd-adminnotes-args-error = Invalid arguments.
|
||||||
|
Usage: adminnotes <UserId OR Username>
|
||||||
|
|
||||||
|
cmd-adminnotes-hint = UserId OR Username
|
||||||
Reference in New Issue
Block a user