Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
4 changed files
with
27 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Discord.Rest; | ||
|
||
namespace Discord.WebSocket | ||
{ | ||
public class DiscordSocketRestClient : DiscordRestClient | ||
{ | ||
internal DiscordSocketRestClient(DiscordRestConfig config, API.DiscordRestApiClient api) : base(config, api) { } | ||
|
||
public new Task LoginAsync(TokenType tokenType, string token, bool validateToken = true) | ||
=> throw new NotSupportedException("The Socket REST wrapper cannot be used to log in or out."); | ||
internal override Task LoginInternalAsync(TokenType tokenType, string token, bool validateToken) | ||
=> throw new NotSupportedException("The Socket REST wrapper cannot be used to log in or out."); | ||
public new Task LogoutAsync() | ||
=> throw new NotSupportedException("The Socket REST wrapper cannot be used to log in or out."); | ||
internal override Task LogoutInternalAsync() | ||
=> throw new NotSupportedException("The Socket REST wrapper cannot be used to log in or out."); | ||
} | ||
} |