Command Logs

This commit is contained in:
hydrant
2021-04-19 11:09:44 +02:00
parent a60f92f992
commit 3d5cf17761
6 changed files with 2117 additions and 0 deletions

View File

@@ -8,6 +8,8 @@ using ReallifeGamemode.Server.Types;
using ReallifeGamemode.Server.Common;
using ReallifeGamemode.Server.Log;
using Microsoft.Extensions.Logging;
using ReallifeGamemode.Database.Entities.Logs;
using ReallifeGamemode.Server.Core.Extensions;
namespace ReallifeGamemode.Server.Core.Commands
{
@@ -33,6 +35,18 @@ namespace ReallifeGamemode.Server.Core.Commands
logger.LogInformation("Player '{Name}' executed command '{command}'", player.Name, command);
using var dbContext = Main.GetDbContext();
var commandLogEntry = new CommandLogEntry()
{
Command = "/" + string.Join(' ', args),
Time = DateTime.Now,
User = player.GetUser(dbContext)
};
dbContext.CommandLogs.Add(commandLogEntry);
dbContext.SaveChanges();
if (legacyCommands.Contains(command))
{
return;