Files
tbd-station-14/Content.Server/Motd/MOTDCommand.cs
TemporalOroboros 93ec824d57 MotD (#13655)
* MOTD

* Message of the Day

* Pretty sure the tests aren't me. Let's check.

* Update Content.Shared/CCVar/CCVars.cs

Co-authored-by: AJCM-git <60196617+AJCM-git@users.noreply.github.com>

* command dependencies and moving MOTD to its own system

* Some doc comments

* Let's try those tests again

* More doc comments, most of the github reviews, and aliases for get-motd and set-motd

* Clear test MOTD

* Localized motd commands and completion hints

* Makes set-motd only show up in the alias command if the player has access to it.

---------

Co-authored-by: AJCM-git <60196617+AJCM-git@users.noreply.github.com>
2023-02-28 08:15:48 -08:00

37 lines
1.5 KiB
C#

using Content.Server.Administration.Managers;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.Motd;
/// <summary>
/// A console command which acts as an alias for <see cref="GetMotdCommand"/> or <see cref="SetMotdCommand"/> depending on the number of arguments given.
/// </summary>
[AnyCommand]
internal sealed class MOTDCommand : LocalizedCommands
{
[Dependency] private readonly IAdminManager _adminManager = default!;
public override string Command => "motd";
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = (IPlayerSession?)shell.Player;
if (args.Length < 1 || (player != null && _adminManager is AdminManager aMan && !aMan.CanCommand(player, "set-motd")))
shell.ConsoleHost.ExecuteCommand(shell.Player, "get-motd");
else
shell.ConsoleHost.ExecuteCommand(shell.Player, $"set-motd {string.Join(" ", args)}");
}
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
var player = (IPlayerSession?)shell.Player;
if (player != null && _adminManager is AdminManager aMan && !aMan.CanCommand(player, "set-motd"))
return CompletionResult.Empty;
if (args.Length == 1)
return CompletionResult.FromHint(Loc.GetString("cmd-set-motd-hint-head"));
return CompletionResult.FromHint(Loc.GetString("cmd-set-motd-hint-cont"));
}
}