fix: NullReferenceException in pin/unpin audit logs (#1780)
This commit is contained in:
@@ -18,9 +18,15 @@ namespace Discord.Rest
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal static MessagePinAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
|
internal static MessagePinAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
|
||||||
|
{
|
||||||
|
RestUser user = null;
|
||||||
|
if (entry.TargetId.HasValue)
|
||||||
{
|
{
|
||||||
var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId);
|
var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId);
|
||||||
return new MessagePinAuditLogData(entry.Options.MessageId.Value, entry.Options.ChannelId.Value, RestUser.Create(discord, userInfo));
|
user = RestUser.Create(discord, userInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new MessagePinAuditLogData(entry.Options.MessageId.Value, entry.Options.ChannelId.Value, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -38,10 +44,10 @@ namespace Discord.Rest
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
public ulong ChannelId { get; }
|
public ulong ChannelId { get; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the user of the message that was pinned.
|
/// Gets the user of the message that was pinned if available.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// A user object representing the user that created the pinned message.
|
/// A user object representing the user that created the pinned message or <see langword="null"/>.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public IUser Target { get; }
|
public IUser Target { get; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,9 +18,15 @@ namespace Discord.Rest
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal static MessageUnpinAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
|
internal static MessageUnpinAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
|
||||||
|
{
|
||||||
|
RestUser user = null;
|
||||||
|
if (entry.TargetId.HasValue)
|
||||||
{
|
{
|
||||||
var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId);
|
var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId);
|
||||||
return new MessageUnpinAuditLogData(entry.Options.MessageId.Value, entry.Options.ChannelId.Value, RestUser.Create(discord, userInfo));
|
user = RestUser.Create(discord, userInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new MessageUnpinAuditLogData(entry.Options.MessageId.Value, entry.Options.ChannelId.Value, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -38,10 +44,10 @@ namespace Discord.Rest
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
public ulong ChannelId { get; }
|
public ulong ChannelId { get; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the user of the message that was unpinned.
|
/// Gets the user of the message that was unpinned if available.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// A user object representing the user that created the unpinned message.
|
/// A user object representing the user that created the unpinned message or <see langword="null"/>.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public IUser Target { get; }
|
public IUser Target { get; }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user