[Feat] New console command: ForceDeadmin (#101)

This commit is contained in:
HitPanda
2024-02-20 17:31:16 +03:00
committed by GitHub
3 changed files with 54 additions and 1 deletions

View File

@@ -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 <Ckey>";
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<IPlayerManager>();
if (!playerManager.TryGetSessionByUsername(ckey, out var player))
{
shell.WriteLine($"Couldn't find player {ckey}");
return;
}
var mgr = IoCManager.Resolve<IAdminManager>();
mgr.DeAdmin(player);
shell.WriteLine($"Deadmined {ckey}");
}
public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
return args.Length == 1 ? CompletionResult.FromHintOptions(CompletionHelper.SessionNames(), "<Player ckey>") : CompletionResult.Empty;
}
}

View File

@@ -46,6 +46,12 @@ public sealed class PandaBanCommand : IPandaCommand
var minutes = (uint) message.Duration!;
var isGlobalBan = (bool) message.Global!;
if (Enum.TryParse(message.Severity!, ignoreCase: true, out NoteSeverity severity))
{
UtkaSendResponse(context, false);
return;
}
var located = await locator.LookupIdByNameOrIdAsync(target);
if (located == null)
{
@@ -101,7 +107,7 @@ public sealed class PandaBanCommand : IPandaCommand
roundId,
playtime,
reason,
NoteSeverity.High,
severity,
player,
null,
serverName);

View File

@@ -141,6 +141,9 @@ public sealed class UtkaBanRequest : PandaBaseRequestEventMessage
[JsonPropertyName("global")]
public bool? Global { get; set; }
[JsonPropertyName("severity")]
public string? Severity { get; set; }
}
public sealed class UtkaBanResponse : PandaBaseMessage