CatStation/Content.Server/Chat/V2/Commands/DeleteChatMessageCommand.cs
Pieter-Jan Briers 5168b5f3d4
IoC source gen compatibility (#43863)
* IoC source gen compatibility

Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter.

* Missed a spot
2026-05-09 03:29:58 +00:00

36 lines
1.1 KiB
C#

using System.Diagnostics;
using Content.Server.Administration;
using Content.Server.Chat.V2.Repository;
using Content.Shared.Administration;
using Robust.Shared.Toolshed;
using Robust.Shared.Toolshed.Errors;
using Robust.Shared.Utility;
namespace Content.Server.Chat.V2.Commands;
[ToolshedCommand, AdminCommand(AdminFlags.Admin)]
public sealed partial class DeleteChatMessageCommand : ToolshedCommand
{
[Dependency] private IEntitySystemManager _manager = default!;
[CommandImplementation("id")]
public void DeleteChatMessage(IInvocationContext ctx, uint messageId)
{
if (!_manager.GetEntitySystem<ChatRepositorySystem>().Delete(messageId))
{
ctx.ReportError(new MessageIdDoesNotExist());
}
}
}
public record struct MessageIdDoesNotExist() : IConError
{
public FormattedMessage DescribeInner()
{
return FormattedMessage.FromUnformatted(Loc.GetString("command-error-deletechatmessage-id-notexist"));
}
public string? Expression { get; set; }
public Vector2i? IssueSpan { get; set; }
public StackTrace? Trace { get; set; }
}