Browse Source

Use IUser properties

pull/1458/head
NeKz 5 years ago
parent
commit
69bbacbb8f
No known key found for this signature in database GPG Key ID: C4257EE7BB20CA1E
4 changed files with 36 additions and 24 deletions
  1. +9
    -6
      src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/BotAddAuditLogData.cs
  2. +9
    -6
      src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageDeleteAuditLogData.cs
  3. +9
    -6
      src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessagePinAuditLogData.cs
  4. +9
    -6
      src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageUnpinAuditLogData.cs

+ 9
- 6
src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/BotAddAuditLogData.cs View File

@@ -1,3 +1,5 @@
using System.Linq;

using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;

@@ -8,22 +10,23 @@ namespace Discord.Rest
/// </summary>
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));
}

/// <summary>
/// Gets the ID of the bot that was added.
/// Gets the bot that was added.
/// </summary>
/// <returns>
/// A <see cref="ulong"/> representing the snowflake identifier for the bot that was added.
/// A user object representing the bot.
/// </returns>
public ulong BotId { get; }
public IUser Target { get; }
}
}

+ 9
- 6
src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageDeleteAuditLogData.cs View File

@@ -1,3 +1,5 @@
using System.Linq;

using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;

@@ -8,16 +10,17 @@ namespace Discord.Rest
/// </summary>
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));
}

/// <summary>
@@ -36,11 +39,11 @@ namespace Discord.Rest
/// </returns>
public ulong ChannelId { get; }
/// <summary>
/// Gets the author of the messages that were deleted.
/// Gets the user of the messages that were deleted.
/// </summary>
/// <returns>
/// A <see cref="ulong"/> representing the snowflake identifier for the user that created the deleted messages.
/// A user object representing the user that created the deleted messages.
/// </returns>
public ulong AuthorId { get; }
public IUser Target { get; }
}
}

+ 9
- 6
src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessagePinAuditLogData.cs View File

@@ -1,3 +1,5 @@
using System.Linq;

using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;

@@ -8,16 +10,17 @@ namespace Discord.Rest
/// </summary>
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));
}

/// <summary>
@@ -35,11 +38,11 @@ namespace Discord.Rest
/// </returns>
public ulong ChannelId { get; }
/// <summary>
/// Gets the author of the message that was pinned.
/// Gets the user of the message that was pinned.
/// </summary>
/// <returns>
/// A <see cref="ulong"/> representing the snowflake identifier for the user whose message was pinned.
/// A user object representing the user that created the pinned message.
/// </returns>
public ulong AuthorId { get; }
public IUser Target { get; }
}
}

+ 9
- 6
src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageUnpinAuditLogData.cs View File

@@ -1,3 +1,5 @@
using System.Linq;

using Model = Discord.API.AuditLog;
using EntryModel = Discord.API.AuditLogEntry;

@@ -8,16 +10,17 @@ namespace Discord.Rest
/// </summary>
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));
}

/// <summary>
@@ -35,11 +38,11 @@ namespace Discord.Rest
/// </returns>
public ulong ChannelId { get; }
/// <summary>
/// Gets the author of the message that was unpinned.
/// Gets the user of the message that was unpinned.
/// </summary>
/// <returns>
/// A <see cref="ulong"/> representing the snowflake identifier for the user whose message was unpinned.
/// A user object representing the user that created the unpinned message.
/// </returns>
public ulong AuthorId { get; }
public IUser Target { get; }
}
}

Loading…
Cancel
Save