Files
Discord.Net/src/Discord.Net.WebSocket/DiscordSocketRestClient.cs
Christopher F 65afd37502 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
2018-12-02 13:37:25 -05:00

21 lines
1017 B
C#

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.");
}
}