You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

RestAuditLogEntry.cs 1.2 kB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System.Linq;
  2. using Model = Discord.API.AuditLog;
  3. using EntryModel = Discord.API.AuditLogEntry;
  4. namespace Discord.Rest
  5. {
  6. public class RestAuditLogEntry : RestEntity<ulong>, IAuditLogEntry
  7. {
  8. private RestAuditLogEntry(BaseDiscordClient discord, Model fullLog, EntryModel model, IUser user)
  9. : base(discord, model.Id)
  10. {
  11. Action = model.Action;
  12. Data = AuditLogHelper.CreateData(discord, fullLog, model);
  13. User = user;
  14. Reason = model.Reason;
  15. }
  16. internal static RestAuditLogEntry Create(BaseDiscordClient discord, Model fullLog, EntryModel model)
  17. {
  18. var userInfo = fullLog.Users.FirstOrDefault(x => x.Id == model.UserId);
  19. IUser user = null;
  20. if (userInfo != null)
  21. user = RestUser.Create(discord, userInfo);
  22. return new RestAuditLogEntry(discord, fullLog, model, user);
  23. }
  24. /// <inheritdoc/>
  25. public ActionType Action { get; }
  26. /// <inheritdoc/>
  27. public IAuditLogData Data { get; }
  28. /// <inheritdoc/>
  29. public IUser User { get; }
  30. /// <inheritdoc/>
  31. public string Reason { get; }
  32. }
  33. }