Files
tbd-station-14/Content.Server/Administration/Commands/DSay.cs
slarticodefast 1469b9484d Add virtual chat API methods in Shared (#40895)
* move chat stuff to shared

* refactor: using cleanup +whitespaces + xml-doc

* review

---------

Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
2025-10-19 19:08:27 +00:00

39 lines
1.1 KiB
C#

using Content.Server.Chat.Systems;
using Content.Shared.Administration;
using Content.Shared.Chat;
using Robust.Shared.Console;
namespace Content.Server.Administration.Commands;
[AdminCommand(AdminFlags.Moderator)]
public sealed class DsayCommand : LocalizedEntityCommands
{
[Dependency] private readonly ChatSystem _chatSystem = default!;
public override string Command => "dsay";
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (shell.Player is not { } player)
{
shell.WriteError(Loc.GetString("shell-cannot-run-command-from-server"));
return;
}
if (player.AttachedEntity is not { Valid: true } entity)
{
shell.WriteError(Loc.GetString("shell-must-be-attached-to-entity"));
return;
}
if (args.Length < 1)
return;
var message = string.Join(" ", args).Trim();
if (string.IsNullOrEmpty(message))
return;
_chatSystem.TrySendInGameOOCMessage(entity, message, InGameOOCChatType.Dead, false, shell, player);
}
}