From 124efdf7e66ee070fbcdde07ed4f20c717c9c1c0 Mon Sep 17 00:00:00 2001
From: Still Hsu <341464@gmail.com>
Date: Sun, 6 May 2018 04:40:14 +0800
Subject: [PATCH] XML Docs
---
src/Discord.Net.Core/CDN.cs | 70 ++++++++++++++++---
src/Discord.Net.Core/DiscordConfig.cs | 51 +++++++++++++-
.../Entities/Messages/IAttachment.cs | 35 ++++++++--
.../Entities/Messages/IEmbed.cs | 64 +++++++++++++----
src/Discord.Net.Core/Entities/Roles/Color.cs | 15 ++--
src/Discord.Net.Core/Entities/Users/IUser.cs | 4 +-
.../Entities/Messages/Attachment.cs | 11 ++-
7 files changed, 211 insertions(+), 39 deletions(-)
diff --git a/src/Discord.Net.Core/CDN.cs b/src/Discord.Net.Core/CDN.cs
index 1b75d0633..0fefc9a0d 100644
--- a/src/Discord.Net.Core/CDN.cs
+++ b/src/Discord.Net.Core/CDN.cs
@@ -8,13 +8,26 @@ namespace Discord
public static class CDN
{
///
- /// Returns the Discord developer application icon.
+ /// Returns an application icon URL.
///
+ /// The application identifier.
+ /// The icon identifier.
+ ///
+ /// A URL pointing to the application's icon.
+ ///
public static string GetApplicationIconUrl(ulong appId, string iconId)
=> iconId != null ? $"{DiscordConfig.CDNUrl}app-icons/{appId}/{iconId}.jpg" : null;
+
///
- /// Returns the user avatar URL based on the and .
+ /// Returns a user avatar URL.
///
+ /// The user snowflake identifier.
+ /// The avatar identifier.
+ /// The size of the image to return in. This can be any power of two between 16 and 2048.
+ /// The format to return.
+ ///
+ /// A URL pointing to the user's avatar in the specified size.
+ ///
public static string GetUserAvatarUrl(ulong userId, string avatarId, ushort size, ImageFormat format)
{
if (avatarId == null)
@@ -26,34 +39,64 @@ namespace Discord
/// Returns the default user avatar URL.
///
/// The discriminator value of a user.
+ ///
+ /// A URL pointing to the user's default avatar when one isn't set.
+ ///
public static string GetDefaultUserAvatarUrl(ushort discriminator)
{
return $"{DiscordConfig.CDNUrl}embed/avatars/{discriminator % 5}.png";
}
///
- /// Returns the icon URL associated with the given guild ID.
+ /// Returns an icon URL.
///
+ /// The guild snowflake identifier.
+ /// The icon identifier.
+ ///
+ /// A URL pointing to the guild's icon.
+ ///
public static string GetGuildIconUrl(ulong guildId, string iconId)
=> iconId != null ? $"{DiscordConfig.CDNUrl}icons/{guildId}/{iconId}.jpg" : null;
///
- /// Returns the guild splash URL associated with the given guild and splash ID.
+ /// Returns a guild splash URL.
///
+ /// The guild snowflake identifier.
+ /// The splash icon identifier.
+ ///
+ /// A URL pointing to the guild's icon.
+ ///
public static string GetGuildSplashUrl(ulong guildId, string splashId)
=> splashId != null ? $"{DiscordConfig.CDNUrl}splashes/{guildId}/{splashId}.jpg" : null;
///
- /// Returns the channel icon URL associated with the given guild and icon ID.
+ /// Returns a channel icon URL.
///
+ /// The channel snowflake identifier.
+ /// The icon identifier.
+ ///
+ /// A URL pointing to the channel's icon.
+ ///
public static string GetChannelIconUrl(ulong channelId, string iconId)
=> iconId != null ? $"{DiscordConfig.CDNUrl}channel-icons/{channelId}/{iconId}.jpg" : null;
///
- /// Returns the emoji URL based on the emoji ID.
+ /// Returns an emoji URL.
///
+ /// The emoji snowflake identifier.
+ /// Whether this emoji is animated.
+ ///
+ /// A URL pointing to the custom emote.
+ ///
public static string GetEmojiUrl(ulong emojiId, bool animated)
=> $"{DiscordConfig.CDNUrl}emojis/{emojiId}.{(animated ? "gif" : "png")}";
///
- /// Returns the rich presence asset URL based on the asset ID and .
+ /// Returns a Rich Presence asset URL.
///
+ /// The application identifier.
+ /// The asset identifier.
+ /// The size of the image to return in. This can be any power of two between 16 and 2048.
+ /// The format to return.
+ ///
+ /// A URL pointing to the asset image in the specified size.
+ ///
public static string GetRichAssetUrl(ulong appId, string assetId, ushort size, ImageFormat format)
{
string extension = FormatToExtension(format, "");
@@ -61,10 +104,21 @@ namespace Discord
}
///
- /// Returns the Spotify album URL based on the album art ID.
+ /// Returns a Spotify album URL.
///
+ /// The identifier for the album art (e.g. 6be8f4c8614ecf4f1dd3ebba8d8692d8ce4951ac).
+ ///
+ /// A URL pointing to the Spotify album art.
+ ///
public static string GetSpotifyAlbumArtUrl(string albumArtId)
=> $"https://i.scdn.co/image/{albumArtId}";
+ ///
+ /// Returns a Spotify direct URL for a track.
+ ///
+ /// The identifier for the track (e.g. 4uLU6hMCjMI75M1A2tKUQC).
+ ///
+ /// A URL pointing to the Spotify track.
+ ///
public static string GetSpotifyDirectUrl(string trackId)
=> $"https://open.spotify.com/track/{trackId}";
diff --git a/src/Discord.Net.Core/DiscordConfig.cs b/src/Discord.Net.Core/DiscordConfig.cs
index b3cdddfa5..3dad011f5 100644
--- a/src/Discord.Net.Core/DiscordConfig.cs
+++ b/src/Discord.Net.Core/DiscordConfig.cs
@@ -8,12 +8,22 @@ namespace Discord
public class DiscordConfig
{
///
- /// Returns the gateway version Discord.Net uses.
+ /// Returns the API version Discord.Net uses.
///
+ ///
+ /// A 32-bit integer representing the API version that Discord.Net uses to communicate with Discord.
+ /// A list of available API version can be seen on the official
+ /// Discord API documentation
+ /// .
+ ///
public const int APIVersion = 6;
///
/// Gets the Discord.Net version, including the build number.
///
+ ///
+ /// A string containing the detailed version information, including its build number; Unknown when
+ /// the version fails to be fetched.
+ ///
public static string Version { get; } =
typeof(DiscordConfig).GetTypeInfo().Assembly.GetCustomAttribute()?.InformationalVersion ??
typeof(DiscordConfig).GetTypeInfo().Assembly.GetName().Version.ToString(3) ??
@@ -22,54 +32,91 @@ namespace Discord
///
/// Gets the user agent that Discord.Net uses in its clients.
///
+ ///
+ /// The user agent used in each Discord.Net request.
+ ///
public static string UserAgent { get; } = $"DiscordBot (https://github.com/RogueException/Discord.Net, v{Version})";
///
/// Returns the base Discord API URL.
///
+ ///
+ /// The Discord API URL using .
+ ///
public static readonly string APIUrl = $"https://discordapp.com/api/v{APIVersion}/";
///
/// Returns the base Discord CDN URL.
///
+ ///
+ /// The base Discord Content Delivery Network (CDN) URL.
+ ///
public const string CDNUrl = "https://cdn.discordapp.com/";
///
- /// Returns the base Discord invite URL.
+ /// Returns the base Discord invite URL.
///
+ ///
+ /// The base Discord invite URL.
+ ///
public const string InviteUrl = "https://discord.gg/";
///
/// Returns the default timeout for requests.
///
+ ///
+ /// The amount of time it takes in milliseconds before a request is timed out.
+ ///
public const int DefaultRequestTimeout = 15000;
///
/// Returns the max length for a Discord message.
///
+ ///
+ /// The maximum length of a message allowed by Discord.
+ ///
public const int MaxMessageSize = 2000;
///
/// Returns the max messages allowed to be in a request.
///
+ ///
+ /// The maximum number of messages that can be gotten per-batch.
+ ///
public const int MaxMessagesPerBatch = 100;
///
/// Returns the max users allowed to be in a request.
///
+ ///
+ /// The maximum number of users that can be gotten per-batch.
+ ///
public const int MaxUsersPerBatch = 1000;
///
/// Returns the max guilds allowed to be in a request.
///
+ ///
+ /// The maximum number of guilds that can be gotten per-batch.
+ ///
public const int MaxGuildsPerBatch = 100;
///
/// Gets or sets how a request should act in the case of an error, by default.
///
+ ///
+ /// The currently set .
+ ///
public RetryMode DefaultRetryMode { get; set; } = RetryMode.AlwaysRetry;
///
/// Gets or sets the minimum log level severity that will be sent to the Log event.
///
+ ///
+ /// The currently set for logging level.
+ ///
public LogSeverity LogLevel { get; set; } = LogSeverity.Info;
///
/// Gets or sets whether the initial log entry should be printed.
///
+ ///
+ /// If set to true, the library will attempt to print the current version of the library, as well as
+ /// the API version it uses on startup.
+ ///
internal bool DisplayInitialLog { get; set; } = true;
}
}
diff --git a/src/Discord.Net.Core/Entities/Messages/IAttachment.cs b/src/Discord.Net.Core/Entities/Messages/IAttachment.cs
index f01876186..c61d8177c 100644
--- a/src/Discord.Net.Core/Entities/Messages/IAttachment.cs
+++ b/src/Discord.Net.Core/Entities/Messages/IAttachment.cs
@@ -6,33 +6,54 @@ namespace Discord
public interface IAttachment
{
///
- /// Gets the snowflake ID of the attachment.
+ /// Gets the ID of this attachment.
///
+ ///
+ /// A snowflake ID associated with this attachment.
+ ///
ulong Id { get; }
///
- /// Gets the filename of the attachment.
+ /// Gets the filename of this attachment.
///
+ ///
+ /// A string containing the full filename of this attachment (e.g. textFile.txt).
+ ///
string Filename { get; }
///
- /// Gets the URL of the attachment.
+ /// Gets the URL of this attachment.
///
+ ///
+ /// A string containing the URL of this attachment.
+ ///
string Url { get; }
///
- /// Gets the proxied URL of the attachment.
+ /// Gets a proxied URL of this attachment.
///
+ ///
+ /// A string containing the proxied URL of this attachment.
+ ///
string ProxyUrl { get; }
///
- /// Gets the file size of the attachment.
+ /// Gets the file size of this attachment.
///
+ ///
+ /// The size of this attachment in bytes.
+ ///
int Size { get; }
///
- /// Gets the height of the attachment if it is an image, or return when it is not.
+ /// Gets the height of this attachment.
///
+ ///
+ /// The height of this attachment if it is a picture; otherwise .
+ ///
int? Height { get; }
///
- /// Gets the width of the attachment if it is an image, or return when it is not.
+ /// Gets the width of this attachment.
///
+ ///
+ /// The width of this attachment if it is a picture; otherwise .
+ ///
int? Width { get; }
}
}
diff --git a/src/Discord.Net.Core/Entities/Messages/IEmbed.cs b/src/Discord.Net.Core/Entities/Messages/IEmbed.cs
index 473a61ed5..1482de20a 100644
--- a/src/Discord.Net.Core/Entities/Messages/IEmbed.cs
+++ b/src/Discord.Net.Core/Entities/Messages/IEmbed.cs
@@ -9,56 +9,96 @@ namespace Discord
public interface IEmbed
{
///
- /// Gets the title URL of the embed.
+ /// Gets the title URL of this embed.
///
+ ///
+ /// A string containing the URL set in a title of the embed.
+ ///
string Url { get; }
///
- /// Gets the title of the embed.
+ /// Gets the title of this embed.
///
+ ///
+ /// The title of the embed.
+ ///
string Title { get; }
///
- /// Gets the description of the embed.
+ /// Gets the description of this embed.
///
+ ///
+ /// The description field of the embed.
+ ///
string Description { get; }
///
- /// Gets the type of the embed.
+ /// Gets the type of this embed.
///
+ ///
+ /// The type of the embed.
+ ///
EmbedType Type { get; }
///
- /// Gets the timestamp of the embed, or if none is set.
+ /// Gets the timestamp of this embed.
///
+ ///
+ /// A based on the timestamp present at the bottom left of the embed, or
+ /// if none is set.
+ ///
DateTimeOffset? Timestamp { get; }
///
- /// Gets the sidebar color of the embed, or if none is set.
+ /// Gets the color of this embed.
///
+ ///
+ /// The color of the embed present on the side of the embed, or if none is set.
+ ///
Color? Color { get; }
///
- /// Gets the image of the embed, or if none is set.
+ /// Gets the image of this embed.
///
+ ///
+ /// The image of the embed, or if none is set.
+ ///
EmbedImage? Image { get; }
///
- /// Gets the video of the embed, or if none is set.
+ /// Gets the video of this embed.
///
+ ///
+ /// The video of the embed, or if none is set.
+ ///
EmbedVideo? Video { get; }
///
- /// Gets the author field of the embed, or if none is set.
+ /// Gets the author field of this embed.
///
+ ///
+ /// The author field of the embed, or if none is set.
+ ///
EmbedAuthor? Author { get; }
///
- /// Gets the footer field of the embed, or if none is set.
+ /// Gets the footer field of this embed.
///
+ ///
+ /// The author field of the embed, or if none is set.
+ ///
EmbedFooter? Footer { get; }
///
- /// Gets the provider of the embed, or if none is set.
+ /// Gets the provider of this embed.
///
+ ///
+ /// The source of the embed, or if none is set.
+ ///
EmbedProvider? Provider { get; }
///
- /// Gets the thumbnail featured in the embed, or if none is set.
+ /// Gets the thumbnail featured in this embed.
///
+ ///
+ /// The thumbnail featured in the embed, or if none is set.
+ ///
EmbedThumbnail? Thumbnail { get; }
///
/// Gets the fields of the embed.
///
+ ///
+ /// An array of the fields of the embed.
+ ///
ImmutableArray Fields { get; }
}
}
diff --git a/src/Discord.Net.Core/Entities/Roles/Color.cs b/src/Discord.Net.Core/Entities/Roles/Color.cs
index cdee5284d..fa7624a57 100644
--- a/src/Discord.Net.Core/Entities/Roles/Color.cs
+++ b/src/Discord.Net.Core/Entities/Roles/Color.cs
@@ -4,7 +4,7 @@ using System.Diagnostics;
namespace Discord
{
///
- /// Represents a Discord color.
+ /// Represents a color used in Discord.
///
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public struct Color
@@ -65,7 +65,7 @@ namespace Discord
///
/// Initializes a struct with the given raw value.
///
- /// A raw value for the color (e.g. 0x607D8B).
+ /// The raw value of the color (e.g. 0x607D8B).
public Color(uint rawValue)
{
RawValue = rawValue;
@@ -73,9 +73,9 @@ namespace Discord
///
/// Initializes a struct with the given RGB bytes.
///
- /// The that represents the red color.
- /// The that represents the green color.
- /// The that represents the blue color.
+ /// The byte that represents the red color.
+ /// The byte that represents the green color.
+ /// The byte that represents the blue color.
public Color(byte r, byte g, byte b)
{
RawValue =
@@ -126,8 +126,11 @@ namespace Discord
}
///
- /// Gets the hexadecimal representation of the color (e.g. #000ccc).
+ /// Gets the hexadecimal representation of the color (e.g. #000ccc).
///
+ ///
+ /// A hexadecimal string of the color.
+ ///
public override string ToString() =>
$"#{Convert.ToString(RawValue, 16)}";
private string DebuggerDisplay =>
diff --git a/src/Discord.Net.Core/Entities/Users/IUser.cs b/src/Discord.Net.Core/Entities/Users/IUser.cs
index aabe4fdb4..e1e6c258f 100644
--- a/src/Discord.Net.Core/Entities/Users/IUser.cs
+++ b/src/Discord.Net.Core/Entities/Users/IUser.cs
@@ -12,11 +12,11 @@ namespace Discord
///
string AvatarId { get; }
///
- /// Returns the URL to this user's avatar.
+ /// Returns a URL to this user's avatar.
///
/// The format to return.
///
- /// The size of the image to return in. Image size can be any power of two between 16 and 2048.
+ /// The size of the image to return in. This can be any power of two between 16 and 2048.
///
///
/// User's avatar URL.
diff --git a/src/Discord.Net.Rest/Entities/Messages/Attachment.cs b/src/Discord.Net.Rest/Entities/Messages/Attachment.cs
index a51ac8e09..0f5aaf438 100644
--- a/src/Discord.Net.Rest/Entities/Messages/Attachment.cs
+++ b/src/Discord.Net.Rest/Entities/Messages/Attachment.cs
@@ -3,7 +3,9 @@ using Model = Discord.API.Attachment;
namespace Discord
{
- /// A Discord attachment.
+ ///
+ /// An attachment file seen in a .
+ ///
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class Attachment : IAttachment
{
@@ -39,7 +41,12 @@ namespace Discord
model.Width.IsSpecified ? model.Width.Value : (int?)null);
}
- /// Returns the filename of the attachment.
+ ///
+ /// Returns the filename of this attachment.
+ ///
+ ///
+ /// A string containing the filename of this attachment.
+ ///
public override string ToString() => Filename;
private string DebuggerDisplay => $"{Filename} ({Size} bytes)";
}