MeCommand.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using Content.Server.Chat.Systems;
  2. using Content.Shared.Administration;
  3. using Robust.Shared.Console;
  4. using Robust.Shared.Enums;
  5. namespace Content.Server.Chat.Commands
  6. {
  7. [AnyCommand]
  8. internal sealed class MeCommand : IConsoleCommand
  9. {
  10. public string Command => "me";
  11. public string Description => "Perform an action.";
  12. public string Help => "me <text>";
  13. public void Execute(IConsoleShell shell, string argStr, string[] args)
  14. {
  15. if (shell.Player is not { } player)
  16. {
  17. shell.WriteError("This command cannot be run from the server.");
  18. return;
  19. }
  20. if (player.Status != SessionStatus.InGame)
  21. return;
  22. if (player.AttachedEntity is not {} playerEntity)
  23. {
  24. shell.WriteError("You don't have an entity!");
  25. return;
  26. }
  27. if (args.Length < 1)
  28. return;
  29. var message = string.Join(" ", args).Trim();
  30. if (string.IsNullOrEmpty(message))
  31. return;
  32. IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<ChatSystem>()
  33. .TrySendInGameICMessage(playerEntity, message, InGameICChatType.Emote, ChatTransmitRange.Normal, false, shell, player);
  34. }
  35. }
  36. }