CatStation/Content.Server/Administration/AdminEventLog/AdminEventLogEui.cs
Samuka e020c43454
Event log tool (#44655)
* button to new ui

* text box and button

* change size

* get the current round

* turn into a command

* fix round id not updating

* button to send log send message to server

* send message to discord

* use another cvar

* general fixes

* update event webhook

* use a place holder

* fix placeholder

* update button name

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

* move to a separate folder

* turn into a fancy window

* add margin

* center text in the button

* move reset button to the left

* update the window

* move send button to the left

* update color

* remove indentation

* set sawmill inside PostInject

* remove random newline

* move PostInject to start of the class

* use darkViolet

* summary

* remove whitespace

* comment

---------

Co-authored-by: AJCM-git <60196617+AJCM-git@users.noreply.github.com>
2026-07-14 23:45:40 +00:00

69 lines
1.9 KiB
C#

using Content.Server.Administration.Managers;
using Content.Server.Discord.WebhookMessages;
using Content.Server.EUI;
using Content.Server.GameTicking;
using Content.Shared.Administration;
using Content.Shared.Administration.AdminEventLog;
using Content.Shared.CCVar;
using Content.Shared.Eui;
using Robust.Shared.Configuration;
namespace Content.Server.Administration.AdminEventLog;
/// <summary>
/// Sends a message to discord after a admin logs a event
/// </summary>
public sealed partial class AdminEventLogEui : BaseEui
{
[Dependency] private IAdminManager _adminManager = default!;
[Dependency] private IConfigurationManager _config = default!;
[Dependency] private EventWebhook _eventWebhook = default!;
[Dependency] private IEntityManager _e = default!;
private int CurrentRoundId => _e.System<GameTicker>().RoundId;
public AdminEventLogEui()
{
IoCManager.InjectDependencies(this);
}
public override async void Opened()
{
base.Opened();
_adminManager.OnPermsChanged += OnPermsChanged;
StateDirty();
}
public override void Closed()
{
base.Closed();
_adminManager.OnPermsChanged -= OnPermsChanged;
}
public override EuiStateBase GetNewState()
{
var state = new AdminEventLogEuiState(CurrentRoundId);
return state;
}
public override async void HandleMessage(EuiMessageBase msg)
{
var message = (AdminEventLogEuiMsg)msg;
_eventWebhook.TrySendMessage(
message.AdminUser,
message.RoundId,
message.EventDescription,
_config.GetCVar(CCVars.DiscordEventWebhook));
}
private void OnPermsChanged(AdminPermsChangedEventArgs args)
{
if (args.Player == Player && !_adminManager.HasAdminFlag(Player, AdminFlags.Admin))
{
Close();
}
}
}