using System;
using System.Linq;
using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;
namespace Discord.Rest
{
///
/// Represents a REST-based audit log entry.
///
public class RestAuditLogEntry : RestEntity, IAuditLogEntry
{
private RestAuditLogEntry(BaseDiscordClient discord, Model fullLog, EntryModel model, IUser user)
: base(discord, model.Id)
{
Action = model.Action;
Data = AuditLogHelper.CreateData(discord, fullLog, model);
User = user;
Reason = model.Reason;
}
internal static RestAuditLogEntry Create(BaseDiscordClient discord, Model fullLog, EntryModel model)
{
var userInfo = fullLog.Users.FirstOrDefault(x => x.Id == model.UserId);
IUser user = null;
if (userInfo != null)
user = RestUser.Create(discord, userInfo);
return new RestAuditLogEntry(discord, fullLog, model, user);
}
///
public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id);
///
public ActionType Action { get; }
///
public IAuditLogData Data { get; }
///
public IUser User { get; }
///
public string Reason { get; }
}
}