OpenUserVisibleNotesCommand.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using Content.Server.Administration.Notes;
  2. using Content.Shared.Administration;
  3. using Content.Shared.CCVar;
  4. using Robust.Shared.Configuration;
  5. using Robust.Shared.Console;
  6. namespace Content.Server.Administration.Commands;
  7. [AnyCommand]
  8. public sealed class OpenUserVisibleNotesCommand : IConsoleCommand
  9. {
  10. [Dependency] private readonly IConfigurationManager _configuration = default!;
  11. [Dependency] private readonly IAdminNotesManager _notes = default!;
  12. public const string CommandName = "adminremarks";
  13. public string Command => CommandName;
  14. public string Description => Loc.GetString("admin-remarks-command-description");
  15. public string Help => $"Usage: {Command}";
  16. public async void Execute(IConsoleShell shell, string argStr, string[] args)
  17. {
  18. if (!_configuration.GetCVar(CCVars.SeeOwnNotes))
  19. {
  20. shell.WriteError(Loc.GetString("admin-remarks-command-error"));
  21. return;
  22. }
  23. if (shell.Player is not { } player)
  24. {
  25. shell.WriteError(Loc.GetString("shell-cannot-run-command-from-server"));
  26. return;
  27. }
  28. await _notes.OpenUserNotesEui(player);
  29. }
  30. }