Allow adminnotes to use username (#9388)

No I'm not going to the ban panel to find someone's GUID.
This commit is contained in:
metalgearsloth
2022-07-04 07:34:16 +10:00
committed by GitHub
parent 176178fad2
commit bdbed1e665

View File

@@ -1,4 +1,5 @@
using Content.Server.Administration.Notes;
using Content.Server.Database;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
@@ -12,7 +13,7 @@ public sealed class OpenAdminNotesCommand : IConsoleCommand
public string Command => CommandName;
public string Description => "Opens the admin notes panel.";
public string Help => $"Usage: {Command} <notedPlayerUserId>";
public string Help => $"Usage: {Command} <notedPlayerUserId OR notedPlayerUsername>";
public async void Execute(IConsoleShell shell, string argStr, string[] args)
{
@@ -28,6 +29,18 @@ public sealed class OpenAdminNotesCommand : IConsoleCommand
{
case 1 when Guid.TryParse(args[0], out notedPlayer):
break;
case 1:
var db = IoCManager.Resolve<IServerDbManager>();
var dbGuid = await db.GetAssignedUserIdAsync(args[0]);
if (dbGuid == null)
{
shell.WriteError($"Unable to find {args[0]} netuserid");
return;
}
notedPlayer = dbGuid.Value;
break;
default:
shell.WriteError($"Invalid arguments.\n{Help}");
return;