Files
tbd-station-14/Content.Server/Announcements/AnnounceCommand.cs
Pieter-Jan Briers c4e2eb9d02 .NET 9 forward compatibility changes (#33421)
This doesn't switch the projects over to .NET 9, but it does make them work on .NET 9 when we decide to switch in the future.
2024-11-20 11:17:45 +11:00

39 lines
1.4 KiB
C#

using Content.Server.Administration;
using Content.Server.Chat;
using Content.Server.Chat.Systems;
using Content.Shared.Administration;
using Robust.Shared.Console;
namespace Content.Server.Announcements
{
[AdminCommand(AdminFlags.Moderator)]
public sealed class AnnounceCommand : IConsoleCommand
{
public string Command => "announce";
public string Description => "Send an in-game announcement.";
public string Help => $"{Command} <sender> <message> or {Command} <message> to send announcement as CentCom.";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var chat = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<ChatSystem>();
if (args.Length == 0)
{
shell.WriteError("Not enough arguments! Need at least 1.");
return;
}
if (args.Length == 1)
{
chat.DispatchGlobalAnnouncement(args[0], colorOverride: Color.Gold);
}
else
{
// Explicit IEnumerable<string> due to overload ambiguity on .NET 9
var message = string.Join(' ', (IEnumerable<string>)new ArraySegment<string>(args, 1, args.Length-1));
chat.DispatchGlobalAnnouncement(message, args[0], colorOverride: Color.Gold);
}
shell.WriteLine("Sent!");
}
}
}