2023-02-28 08:15:48 -08:00
using Content.Server.Administration.Managers ;
using Content.Shared.Administration ;
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" ;
2023-10-28 09:59:53 +11:00
2023-02-28 08:15:48 -08:00
public override void Execute ( IConsoleShell shell , string argStr , string [ ] args )
{
2023-10-28 09:59:53 +11:00
var player = shell . Player ;
2023-02-28 08:15:48 -08:00
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 )
{
2023-10-28 09:59:53 +11:00
var player = shell . Player ;
2023-02-28 08:15:48 -08:00
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" ) ) ;
}
}