[Feat] New console command: ForceDeadmin (#101)
This commit is contained in:
44
Content.Server/_White/Commands/ForceDeadminCommand.cs
Normal file
44
Content.Server/_White/Commands/ForceDeadminCommand.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -46,6 +46,12 @@ public sealed class PandaBanCommand : IPandaCommand
|
|||||||
var minutes = (uint) message.Duration!;
|
var minutes = (uint) message.Duration!;
|
||||||
var isGlobalBan = (bool) message.Global!;
|
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);
|
var located = await locator.LookupIdByNameOrIdAsync(target);
|
||||||
if (located == null)
|
if (located == null)
|
||||||
{
|
{
|
||||||
@@ -101,7 +107,7 @@ public sealed class PandaBanCommand : IPandaCommand
|
|||||||
roundId,
|
roundId,
|
||||||
playtime,
|
playtime,
|
||||||
reason,
|
reason,
|
||||||
NoteSeverity.High,
|
severity,
|
||||||
player,
|
player,
|
||||||
null,
|
null,
|
||||||
serverName);
|
serverName);
|
||||||
|
|||||||
@@ -141,6 +141,9 @@ public sealed class UtkaBanRequest : PandaBaseRequestEventMessage
|
|||||||
|
|
||||||
[JsonPropertyName("global")]
|
[JsonPropertyName("global")]
|
||||||
public bool? Global { get; set; }
|
public bool? Global { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("severity")]
|
||||||
|
public string? Severity { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class UtkaBanResponse : PandaBaseMessage
|
public sealed class UtkaBanResponse : PandaBaseMessage
|
||||||
|
|||||||
Reference in New Issue
Block a user