feature: add DiscordSocketRestClient (#1198)
* feature: add DiscordSocketRestClient this resolves #803. Users can access a DiscordSocketRestClient from the new `DiscordSocketClient.Rest` property. DiscordSocketRestClient is a wrapper over DiscordRestClient with certain state-modifying methods, such as Login/Logout disabled, to prevent users from breaking the client state. DiscordSocketRestClient uses the same API client as the DiscordSocketClient, allowing for shared ratelimiting - meaning users can now force HTTP requests without needing to wory about running into 429s. * fix: disallow users from bypassing shadowed login
This commit is contained in:
@@ -42,9 +42,10 @@ namespace Discord.WebSocket
|
||||
private int _nextAudioId;
|
||||
private DateTimeOffset? _statusSince;
|
||||
private RestApplication _applicationInfo;
|
||||
|
||||
private bool _isDisposed;
|
||||
|
||||
/// <summary> Provides access to a REST-only client with a shared state from this client. </summary>
|
||||
public DiscordSocketRestClient Rest { get; }
|
||||
/// <summary> Gets the shard of of this client. </summary>
|
||||
public int ShardId { get; }
|
||||
/// <summary> Gets the current connection state of this client. </summary>
|
||||
@@ -128,6 +129,7 @@ namespace Discord.WebSocket
|
||||
AlwaysDownloadUsers = config.AlwaysDownloadUsers;
|
||||
HandlerTimeout = config.HandlerTimeout;
|
||||
State = new ClientState(0, 0);
|
||||
Rest = new DiscordSocketRestClient(config, ApiClient);
|
||||
_heartbeatTimes = new ConcurrentQueue<long>();
|
||||
|
||||
_stateLock = new SemaphoreSlim(1, 1);
|
||||
|
||||
Reference in New Issue
Block a user