From d8ad2315446dd9a7412689793e879aad69ab163f Mon Sep 17 00:00:00 2001 From: EnefFlow Date: Tue, 20 Feb 2024 16:33:03 +0300 Subject: [PATCH] add: Added forcedeadmin command --- .../_White/Commands/ForceDeadminCommand.cs | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Content.Server/_White/Commands/ForceDeadminCommand.cs diff --git a/Content.Server/_White/Commands/ForceDeadminCommand.cs b/Content.Server/_White/Commands/ForceDeadminCommand.cs new file mode 100644 index 0000000000..dc8cf23128 --- /dev/null +++ b/Content.Server/_White/Commands/ForceDeadminCommand.cs @@ -0,0 +1,44 @@ +using Content.Server.Administration; +using Content.Server.Administration.Managers; +using Content.Shared.Administration; +using JetBrains.Annotations; +using Robust.Server.Player; +using Robust.Shared.Console; + +namespace Content.Server._White.Commands; + +[UsedImplicitly] +[AdminCommand(AdminFlags.Permissions)] +public sealed class ForceDeadminCommand : IConsoleCommand +{ + public string Command => "forcedeadmin"; + public string Description => "Forces someone to deadmin."; + public string Help => "forcedeadmin "; + public void Execute(IConsoleShell shell, string argStr, string[] args) + { + if (args.Length < 1) + { + shell.WriteLine("Didn't specify player."); + return; + } + + var ckey = args[0]; + var playerManager = IoCManager.Resolve(); + + if (!playerManager.TryGetSessionByUsername(ckey, out var player)) + { + shell.WriteLine($"Couldn't find player {ckey}"); + return; + } + + var mgr = IoCManager.Resolve(); + mgr.DeAdmin(player); + + shell.WriteLine($"Deadmined {ckey}"); + } + + public CompletionResult GetCompletion(IConsoleShell shell, string[] args) + { + return args.Length == 1 ? CompletionResult.FromHintOptions(CompletionHelper.SessionNames(), "") : CompletionResult.Empty; + } +}