From 69bbacbb8f6f892446177a1676e8f8c1e2b90511 Mon Sep 17 00:00:00 2001 From: NeKz Date: Fri, 6 Mar 2020 21:44:00 +0100 Subject: [PATCH] Use IUser properties --- .../AuditLogs/DataTypes/BotAddAuditLogData.cs | 15 +++++++++------ .../DataTypes/MessageDeleteAuditLogData.cs | 15 +++++++++------ .../AuditLogs/DataTypes/MessagePinAuditLogData.cs | 15 +++++++++------ .../DataTypes/MessageUnpinAuditLogData.cs | 15 +++++++++------ 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/BotAddAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/BotAddAuditLogData.cs index 27d0096bd..0d12e4609 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/BotAddAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/BotAddAuditLogData.cs @@ -1,3 +1,5 @@ +using System.Linq; + using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; @@ -8,22 +10,23 @@ namespace Discord.Rest /// public class BotAddAuditLogData : IAuditLogData { - private BotAddAuditLogData(ulong botId) + private BotAddAuditLogData(IUser bot) { - BotId = botId; + Target = bot; } internal static BotAddAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry) { - return new BotAddAuditLogData(entry.TargetId.Value); + var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId); + return new BotAddAuditLogData(RestUser.Create(discord, userInfo)); } /// - /// Gets the ID of the bot that was added. + /// Gets the bot that was added. /// /// - /// A representing the snowflake identifier for the bot that was added. + /// A user object representing the bot. /// - public ulong BotId { get; } + public IUser Target { get; } } } diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageDeleteAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageDeleteAuditLogData.cs index 37e964c19..66b3f7d83 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageDeleteAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageDeleteAuditLogData.cs @@ -1,3 +1,5 @@ +using System.Linq; + using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; @@ -8,16 +10,17 @@ namespace Discord.Rest /// public class MessageDeleteAuditLogData : IAuditLogData { - private MessageDeleteAuditLogData(ulong channelId, int count, ulong authorId) + private MessageDeleteAuditLogData(ulong channelId, int count, IUser user) { ChannelId = channelId; MessageCount = count; - AuthorId = authorId; + Target = user; } internal static MessageDeleteAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry) { - return new MessageDeleteAuditLogData(entry.Options.ChannelId.Value, entry.Options.Count.Value, entry.TargetId.Value); + var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId); + return new MessageDeleteAuditLogData(entry.Options.ChannelId.Value, entry.Options.Count.Value, RestUser.Create(discord, userInfo)); } /// @@ -36,11 +39,11 @@ namespace Discord.Rest /// public ulong ChannelId { get; } /// - /// Gets the author of the messages that were deleted. + /// Gets the user of the messages that were deleted. /// /// - /// A representing the snowflake identifier for the user that created the deleted messages. + /// A user object representing the user that created the deleted messages. /// - public ulong AuthorId { get; } + public IUser Target { get; } } } diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessagePinAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessagePinAuditLogData.cs index 52b18535a..020171152 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessagePinAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessagePinAuditLogData.cs @@ -1,3 +1,5 @@ +using System.Linq; + using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; @@ -8,16 +10,17 @@ namespace Discord.Rest /// public class MessagePinAuditLogData : IAuditLogData { - private MessagePinAuditLogData(ulong messageId, ulong channelId, ulong authorId) + private MessagePinAuditLogData(ulong messageId, ulong channelId, IUser user) { MessageId = messageId; ChannelId = channelId; - AuthorId = authorId; + Target = user; } internal static MessagePinAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry) { - return new MessagePinAuditLogData(entry.Options.MessageId.Value, entry.Options.ChannelId.Value, entry.TargetId.Value); + 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)); } /// @@ -35,11 +38,11 @@ namespace Discord.Rest /// public ulong ChannelId { get; } /// - /// Gets the author of the message that was pinned. + /// Gets the user of the message that was pinned. /// /// - /// A representing the snowflake identifier for the user whose message was pinned. + /// A user object representing the user that created the pinned message. /// - public ulong AuthorId { get; } + public IUser Target { get; } } } diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageUnpinAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageUnpinAuditLogData.cs index 66769ef96..1b3ff96f3 100644 --- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageUnpinAuditLogData.cs +++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageUnpinAuditLogData.cs @@ -1,3 +1,5 @@ +using System.Linq; + using Model = Discord.API.AuditLog; using EntryModel = Discord.API.AuditLogEntry; @@ -8,16 +10,17 @@ namespace Discord.Rest /// public class MessageUnpinAuditLogData : IAuditLogData { - private MessageUnpinAuditLogData(ulong messageId, ulong channelId, ulong authorId) + private MessageUnpinAuditLogData(ulong messageId, ulong channelId, IUser user) { MessageId = messageId; ChannelId = channelId; - AuthorId = authorId; + Target = user; } internal static MessageUnpinAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry) { - return new MessageUnpinAuditLogData(entry.Options.MessageId.Value, entry.Options.ChannelId.Value, entry.TargetId.Value); + 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)); } /// @@ -35,11 +38,11 @@ namespace Discord.Rest /// public ulong ChannelId { get; } /// - /// Gets the author of the message that was unpinned. + /// Gets the user of the message that was unpinned. /// /// - /// A representing the snowflake identifier for the user whose message was unpinned. + /// A user object representing the user that created the unpinned message. /// - public ulong AuthorId { get; } + public IUser Target { get; } } }