Files
tbd-station-14/Content.Server/Chat/V2/Commands/DeleteChatMessageCommand.cs
Leon Friedrich 06e2bba8ab Toolshed refactor (#33598)
* Content changes for engine toolshed PR

* add contains command

* more permissive commands
2024-12-21 17:45:48 +11:00

37 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 class DeleteChatMessageCommand : ToolshedCommand
{
[Dependency] private readonly 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; }
}