Skip to content

Commit

Permalink
Add partial documentation for audit log impl
Browse files Browse the repository at this point in the history
  • Loading branch information
Still Hsu committed May 26, 2018
1 parent 5d1621a commit 098ead9
Show file tree
Hide file tree
Showing 13 changed files with 244 additions and 24 deletions.
12 changes: 12 additions & 0 deletions src/Discord.Net.Core/DiscordConfig.cs
Expand Up @@ -93,7 +93,19 @@ public class DiscordConfig
/// The maximum number of guilds that can be gotten per-batch.
/// </returns>
public const int MaxGuildsPerBatch = 100;
/// <summary>
/// Returns the max user reactions allowed to be in a request.
/// </summary>
/// <returns>
/// The maximum number of user reactions that can be gotten per-batch.
/// </returns>
public const int MaxUserReactionsPerBatch = 100;
/// <summary>
/// Returns the max audit log entries allowed to be in a request.
/// </summary>
/// <returns>
/// The maximum number of audit log entries that can be gotten per-batch.
/// </returns>
public const int MaxAuditLogEntriesPerBatch = 100;

/// <summary>
Expand Down
8 changes: 1 addition & 7 deletions src/Discord.Net.Core/Entities/AuditLogs/IAuditLogData.cs
@@ -1,13 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Discord
{
/// <summary>
/// Represents data applied to an <see cref="IAuditLogEntry"/>
/// Represents data applied to an <see cref="IAuditLogEntry"/>.
/// </summary>
public interface IAuditLogData
{ }
Expand Down
21 changes: 18 additions & 3 deletions src/Discord.Net.Core/Entities/Guilds/IGuild.cs
Expand Up @@ -22,7 +22,8 @@ public interface IGuild : IDeletable, ISnowflakeEntity
/// automatically moved to the AFK voice channel.
/// </summary>
/// <returns>
/// The amount of time in seconds for a user to be marked as inactive and moved into the AFK voice channel.
/// An <see cref="Int32"/> representing the amount of time in seconds for a user to be marked as inactive
/// and moved into the AFK voice channel.
/// </returns>
int AFKTimeout { get; }
/// <summary>
Expand Down Expand Up @@ -94,8 +95,12 @@ public interface IGuild : IDeletable, ISnowflakeEntity
bool Available { get; }

/// <summary>
/// Gets the ID of the AFK voice channel for this guild, or <c>null</c> if none is set.
/// Gets the ID of the AFK voice channel for this guild.
/// </summary>
/// <returns>
/// An <see cref="UInt64" /> representing the snowflake identifier of the AFK voice channel; <c>null</c> if
/// none is set.
/// </returns>
ulong? AFKChannelId { get; }
/// <summary>
/// Gets the ID of the the default channel for this guild.
Expand Down Expand Up @@ -542,7 +547,17 @@ public interface IGuild : IDeletable, ISnowflakeEntity
/// </returns>
Task<int> PruneUsersAsync(int days = 30, bool simulate = false, RequestOptions options = null);

/// <summary> Gets the specified number of audit log entries for this guild. </summary>
/// <summary>
/// Gets the specified number of audit log entries for this guild.
/// </summary>
/// <param name="limit">The number of audit log entries to fetch.</param>
/// <param name="mode">
/// The <see cref="CacheMode" /> that determines whether the object should be fetched from cache.
/// </param>
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// An awaitable <see cref="Task"/> containing a collection of requested audit log entries.
/// </returns>
Task<IReadOnlyCollection<IAuditLogEntry>> GetAuditLogAsync(int limit = DiscordConfig.MaxAuditLogEntriesPerBatch,
CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);

Expand Down
7 changes: 5 additions & 2 deletions src/Discord.Net.Core/RequestOptions.cs
Expand Up @@ -25,9 +25,12 @@ public class RequestOptions
public RetryMode? RetryMode { get; set; }
public bool HeaderOnly { get; internal set; }
/// <summary>
/// Gets or sets the reason for this action in the guild's audit log. Note that this property may not apply
/// to every action.
/// Gets or sets the reason for this action in the guild's audit log.
/// </summary>
/// <remarks>
/// Gets or sets the reason that will be written to the guild's audit log if applicable. This may not apply
/// to all actions.
/// </remarks>
public string AuditLogReason { get; set; }

internal bool IgnoreState { get; set; }
Expand Down
@@ -1,10 +1,13 @@
using System.Linq;
using System.Linq;

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

namespace Discord.Rest
{
/// <summary>
/// Represents an audit log data for a ban action.
/// </summary>
public class BanAuditLogData : IAuditLogData
{
private BanAuditLogData(IUser user)
Expand All @@ -18,6 +21,9 @@ internal static BanAuditLogData Create(BaseDiscordClient discord, Model log, Ent
return new BanAuditLogData(RestUser.Create(discord, userInfo));
}

/// <summary>
/// Gets the user that was banned.
/// </summary>
public IUser Target { get; }
}
}
@@ -1,4 +1,3 @@
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using System.Linq;

Expand All @@ -7,6 +6,9 @@

namespace Discord.Rest
{
/// <summary>
/// Represents an audit log data for a channel creation.
/// </summary>
public class ChannelCreateAuditLogData : IAuditLogData
{
private ChannelCreateAuditLogData(ulong id, string name, ChannelType type, IReadOnlyCollection<Overwrite> overwrites)
Expand Down Expand Up @@ -44,9 +46,33 @@ internal static ChannelCreateAuditLogData Create(BaseDiscordClient discord, Mode
return new ChannelCreateAuditLogData(entry.TargetId.Value, name, type, overwrites.ToReadOnlyCollection());
}

/// <summary>
/// Gets the snowflake ID of the created channel.
/// </summary>
/// <returns>
/// An <see cref="ulong"/> representing the snowflake identifier for the created channel.
/// </returns>
public ulong ChannelId { get; }
/// <summary>
/// Gets the name of the created channel.
/// </summary>
/// <returns>
/// A string containing the name of the created channel.
/// </returns>
public string ChannelName { get; }
/// <summary>
/// Gets the type of the created channel.
/// </summary>
/// <returns>
/// The type of channel that was created.
/// </returns>
public ChannelType ChannelType { get; }
/// <summary>
/// Gets a collection of permission overwrites that was assigned to the created channel.
/// </summary>
/// <returns>
/// A collection of permission <see cref="Overwrite" />.
/// </returns>
public IReadOnlyCollection<Overwrite> Overwrites { get; }
}
}
@@ -1,14 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

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

namespace Discord.Rest
{
/// <summary>
/// Represents an audit log data for a channel deletion.
/// </summary>
public class ChannelDeleteAuditLogData : IAuditLogData
{
private ChannelDeleteAuditLogData(ulong id, string name, ChannelType type, IReadOnlyCollection<Overwrite> overwrites)
Expand Down Expand Up @@ -37,9 +37,33 @@ internal static ChannelDeleteAuditLogData Create(BaseDiscordClient discord, Mode
return new ChannelDeleteAuditLogData(id, name, type, overwrites.ToReadOnlyCollection());
}

/// <summary>
/// Gets the snowflake ID of the deleted channel.
/// </summary>
/// <returns>
/// An <see cref="ulong"/> representing the snowflake identifier for the deleted channel.
/// </returns>
public ulong ChannelId { get; }
/// <summary>
/// Gets the name of the deleted channel.
/// </summary>
/// <returns>
/// A string containing the name of the deleted channel.
/// </returns>
public string ChannelName { get; }
/// <summary>
/// Gets the type of the deleted channel.
/// </summary>
/// <returns>
/// The type of channel that was deleted.
/// </returns>
public ChannelType ChannelType { get; }
/// <summary>
/// Gets a collection of permission overwrites that was assigned to the deleted channel.
/// </summary>
/// <returns>
/// A collection of permission <see cref="Overwrite" />.
/// </returns>
public IReadOnlyCollection<Overwrite> Overwrites { get; }
}
}
29 changes: 29 additions & 0 deletions src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelInfo.cs
@@ -1,5 +1,8 @@
namespace Discord.Rest
{
/// <summary>
/// Represents information for a channel.
/// </summary>
public struct ChannelInfo
{
internal ChannelInfo(string name, string topic, int? bitrate, int? limit)
Expand All @@ -10,9 +13,35 @@ internal ChannelInfo(string name, string topic, int? bitrate, int? limit)
UserLimit = limit;
}

/// <summary>
/// Gets the name of this channel.
/// </summary>
/// <returns>
/// A string containing the name of this channel.
/// </returns>
public string Name { get; }
/// <summary>
/// Gets the topic of this channel.
/// </summary>
/// <returns>
/// A string containing the topic of this channel, if any.
/// </returns>
public string Topic { get; }
/// <summary>
/// Gets the bitrate of this channel if applicable.
/// </summary>
/// <returns>
/// An <see cref="System.Int32"/> representing the bitrate set for the voice channel; <c>null</c> if not
/// applicable.
/// </returns>
public int? Bitrate { get; }
/// <summary>
/// Gets the number of users allowed to be in this channel if applicable.
/// </summary>
/// <returns>
/// An <see cref="System.Int32" /> representing the number of users allowed to be in this voice channel;
/// <c>null</c> if not applicable.
/// </returns>
public int? UserLimit { get; }
}
}
@@ -1,10 +1,13 @@
using System.Linq;
using System.Linq;

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

namespace Discord.Rest
{
/// <summary>
/// Represents an audit log data for a channel update.
/// </summary>
public class ChannelUpdateAuditLogData : IAuditLogData
{
private ChannelUpdateAuditLogData(ulong id, ChannelInfo before, ChannelInfo after)
Expand Down Expand Up @@ -38,6 +41,12 @@ internal static ChannelUpdateAuditLogData Create(BaseDiscordClient discord, Mode
return new ChannelUpdateAuditLogData(entry.TargetId.Value, before, after);
}

/// <summary>
/// Gets the snowflake ID of the updated channel.
/// </summary>
/// <returns>
/// An <see cref="ulong"/> representing the snowflake identifier for the updated channel.
/// </returns>
public ulong ChannelId { get; }
public ChannelInfo Before { get; set; }
public ChannelInfo After { get; set; }
Expand Down
@@ -1,14 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

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

namespace Discord.Rest
{
/// <summary>
/// Represents an audit log data for an emoji creation.
/// </summary>
public class EmoteCreateAuditLogData : IAuditLogData
{
private EmoteCreateAuditLogData(ulong id, string name)
Expand All @@ -25,7 +24,19 @@ internal static EmoteCreateAuditLogData Create(BaseDiscordClient discord, Model
return new EmoteCreateAuditLogData(entry.TargetId.Value, emoteName);
}

/// <summary>
/// Gets the snowflake ID of the created emoji.
/// </summary>
/// <returns>
/// An <see cref="System.UInt64"/> representing the snowflake identifier for the created emoji.
/// </returns>
public ulong EmoteId { get; }
/// <summary>
/// Gets the name of the created emoji.
/// </summary>
/// <returns>
/// A string containing the name of the created emoji.
/// </returns>
public string Name { get; }
}
}
@@ -1,10 +1,13 @@
using System.Linq;
using System.Linq;

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

namespace Discord.Rest
{
/// <summary>
/// Represents an audit log data for an emoji deletion.
/// </summary>
public class EmoteDeleteAuditLogData : IAuditLogData
{
private EmoteDeleteAuditLogData(ulong id, string name)
Expand All @@ -22,7 +25,19 @@ internal static EmoteDeleteAuditLogData Create(BaseDiscordClient discord, Model
return new EmoteDeleteAuditLogData(entry.TargetId.Value, emoteName);
}

/// <summary>
/// Gets the snowflake ID of the deleted emoji.
/// </summary>
/// <returns>
/// An <see cref="System.UInt64"/> representing the snowflake identifier for the deleted emoji.
/// </returns>
public ulong EmoteId { get; }
/// <summary>
/// Gets the name of the deleted emoji.
/// </summary>
/// <returns>
/// A string containing the name of the deleted emoji.
/// </returns>
public string Name { get; }
}
}

0 comments on commit 098ead9

Please sign in to comment.