fix: Audit log UserId can be null (#1794)

This commit is contained in:
Paulo
2021-03-10 16:50:14 -03:00
committed by GitHub
parent d2518db9a8
commit d41aeee4fe
2 changed files with 2 additions and 2 deletions

View File

@@ -7,7 +7,7 @@ namespace Discord.API
[JsonProperty("target_id")]
public ulong? TargetId { get; set; }
[JsonProperty("user_id")]
public ulong UserId { get; set; }
public ulong? UserId { get; set; }
[JsonProperty("changes")]
public AuditLogChange[] Changes { get; set; }

View File

@@ -22,7 +22,7 @@ namespace Discord.Rest
internal static RestAuditLogEntry Create(BaseDiscordClient discord, Model fullLog, EntryModel model)
{
var userInfo = fullLog.Users.FirstOrDefault(x => x.Id == model.UserId);
var userInfo = model.UserId != null ? fullLog.Users.FirstOrDefault(x => x.Id == model.UserId) : null;
IUser user = null;
if (userInfo != null)
user = RestUser.Create(discord, userInfo);