diff --git a/src/Discord.Net/Net/Rest/DefaultRestClient.cs b/src/Discord.Net/Net/Rest/DefaultRestClient.cs
index bcad2ece4..daaa2ba96 100644
--- a/src/Discord.Net/Net/Rest/DefaultRestClient.cs
+++ b/src/Discord.Net/Net/Rest/DefaultRestClient.cs
@@ -13,6 +13,7 @@ using System.Threading.Tasks;
namespace Discord.Net.Rest
{
+ /// A default implementation of a
public sealed class DefaultRestClient : IRestClient
{
private const int HR_SECURECHANNELFAILED = -2146233079;
@@ -24,6 +25,7 @@ namespace Discord.Net.Rest
private CancellationToken _cancelToken, _parentToken;
private bool _isDisposed;
+ /// Creates a new instance of
public DefaultRestClient(string baseUrl)
{
_baseUrl = baseUrl;
@@ -50,23 +52,27 @@ namespace Discord.Net.Rest
_isDisposed = true;
}
}
+ /// Disposes any resources allocated by this instance.
public void Dispose()
{
Dispose(true);
}
+ /// Sets a header to be used in REST requests.
public void SetHeader(string key, string value)
{
_client.DefaultRequestHeaders.Remove(key);
if (value != null)
_client.DefaultRequestHeaders.Add(key, value);
}
+ /// Sets the global cancellation token for any requests made by this instance.
public void SetCancelToken(CancellationToken cancelToken)
{
_parentToken = cancelToken;
_cancelToken = CancellationTokenSource.CreateLinkedTokenSource(_parentToken, _cancelTokenSource.Token).Token;
}
+ /// Sends a request with no body to the given endpoint.
public async Task SendAsync(string method, string endpoint, bool headerOnly = false)
{
string uri = Path.Combine(_baseUrl, endpoint);
diff --git a/src/Discord.Net/Net/RpcException.cs b/src/Discord.Net/Net/RpcException.cs
index 195fad73f..d6cfdebad 100644
--- a/src/Discord.Net/Net/RpcException.cs
+++ b/src/Discord.Net/Net/RpcException.cs
@@ -2,11 +2,15 @@
namespace Discord
{
+ /// An exception thrown whenever an RPC error occurs.
public class RpcException : Exception
{
+ /// The code for this error.
public int ErrorCode { get; }
+ /// The reason this error occured.
public string Reason { get; }
+ /// Creates a new instance of
public RpcException(int errorCode, string reason = null)
: base($"The server sent error {errorCode}{(reason != null ? $": \"{reason}\"" : "")}")
{
diff --git a/src/Discord.Net/Rest/DiscordRestClient.cs b/src/Discord.Net/Rest/DiscordRestClient.cs
index 11cf10747..e08b8f72c 100644
--- a/src/Discord.Net/Rest/DiscordRestClient.cs
+++ b/src/Discord.Net/Rest/DiscordRestClient.cs
@@ -15,15 +15,19 @@ using Discord.WebSocket;
namespace Discord.Rest
{
+ /// A client which invokes Discord's REST API.
public class DiscordRestClient : IDiscordClient
{
private readonly object _eventLock = new object();
+ /// Fired whenever a message is logged.
public event Func Log { add { _logEvent.Add(value); } remove { _logEvent.Remove(value); } }
private readonly AsyncEvent> _logEvent = new AsyncEvent>();
+ /// Fired whenever the client logs in.
public event Func LoggedIn { add { _loggedInEvent.Add(value); } remove { _loggedInEvent.Remove(value); } }
private readonly AsyncEvent> _loggedInEvent = new AsyncEvent>();
+ /// Fired whenever the client logs out.
public event Func LoggedOut { add { _loggedOutEvent.Add(value); } remove { _loggedOutEvent.Remove(value); } }
private readonly AsyncEvent> _loggedOutEvent = new AsyncEvent>();
@@ -33,12 +37,15 @@ namespace Discord.Rest
private bool _isFirstLogSub;
internal bool _isDisposed;
+ /// The API client used for making API calls.
public API.DiscordRestApiClient ApiClient { get; }
internal LogManager LogManager { get; }
+ /// The current login state of the client.
public LoginState LoginState { get; private set; }
/// Creates a new REST-only discord client.
public DiscordRestClient() : this(new DiscordRestConfig()) { }
+ /// Creates a new REST-only discord client.
public DiscordRestClient(DiscordRestConfig config) : this(config, CreateApiClient(config)) { }
/// Creates a new REST-only discord client.
internal DiscordRestClient(DiscordRestConfig config, API.DiscordRestApiClient client)
@@ -103,6 +110,7 @@ namespace Discord.Rest
await _loggedInEvent.InvokeAsync().ConfigureAwait(false);
}
+ /// Validates a token with the given type.
protected virtual async Task ValidateTokenAsync(TokenType tokenType, string token)
{
try
@@ -121,6 +129,7 @@ namespace Discord.Rest
throw new ArgumentException("Token validation failed", nameof(token), ex);
}
}
+ /// A Promise for when the client successfully logs in.
protected virtual Task OnLoginAsync(TokenType tokenType, string token) => Task.CompletedTask;
@@ -149,6 +158,7 @@ namespace Discord.Rest
await _loggedOutEvent.InvokeAsync().ConfigureAwait(false);
}
+ /// A Promise for when the client successfully logs out.
protected virtual Task OnLogoutAsync() => Task.CompletedTask;
///