Skip to content

Commit

Permalink
fix: Audit log UserId can be null (#1794)
Browse files Browse the repository at this point in the history
  • Loading branch information
SubZero0 authored Mar 10, 2021
1 parent d2518db commit d41aeee
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Discord.Net.Rest/API/Common/AuditLogEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ internal class AuditLogEntry
[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; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private RestAuditLogEntry(BaseDiscordClient discord, Model fullLog, EntryModel m

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);
Expand Down

0 comments on commit d41aeee

Please sign in to comment.