@ -82,12 +82,12 @@ namespace Discord.API
{
{
switch ( tokenType )
switch ( tokenType )
{
{
case default ( TokenType ) :
return token ;
case TokenType . Bot :
case TokenType . Bot :
return $"Bot {token}" ;
return $"Bot {token}" ;
case TokenType . Bearer :
case TokenType . Bearer :
return $"Bearer {token}" ;
return $"Bearer {token}" ;
case TokenType . User :
return token ;
default :
default :
throw new ArgumentException ( message : "Unknown OAuth token type." , paramName : nameof ( tokenType ) ) ;
throw new ArgumentException ( message : "Unknown OAuth token type." , paramName : nameof ( tokenType ) ) ;
}
}
@ -127,7 +127,7 @@ namespace Discord.API
{
{
_loginCancelToken ? . Dispose ( ) ;
_loginCancelToken ? . Dispose ( ) ;
_loginCancelToken = new CancellationTokenSource ( ) ;
_loginCancelToken = new CancellationTokenSource ( ) ;
AuthTokenType = TokenType . User ;
AuthToken = null ;
AuthToken = null ;
await RequestQueue . SetCancelTokenAsync ( _loginCancelToken . Token ) . ConfigureAwait ( false ) ;
await RequestQueue . SetCancelTokenAsync ( _loginCancelToken . Token ) . ConfigureAwait ( false ) ;
RestClient . SetCancelToken ( _loginCancelToken . Token ) ;
RestClient . SetCancelToken ( _loginCancelToken . Token ) ;
@ -186,7 +186,7 @@ namespace Discord.API
{
{
options = options ? ? new RequestOptions ( ) ;
options = options ? ? new RequestOptions ( ) ;
options . HeaderOnly = true ;
options . HeaderOnly = true ;
options . BucketId = bucketId;
options . BucketId = AuthTokenType = = TokenType . User ? ClientBucket . Get ( clientBucket ) . Id : bucketId;
var request = new RestRequest ( RestClient , method , endpoint , options ) ;
var request = new RestRequest ( RestClient , method , endpoint , options ) ;
await SendInternalAsync ( method , endpoint , request ) . ConfigureAwait ( false ) ;
await SendInternalAsync ( method , endpoint , request ) . ConfigureAwait ( false ) ;
@ -200,7 +200,7 @@ namespace Discord.API
{
{
options = options ? ? new RequestOptions ( ) ;
options = options ? ? new RequestOptions ( ) ;
options . HeaderOnly = true ;
options . HeaderOnly = true ;
options . BucketId = bucketId;
options . BucketId = AuthTokenType = = TokenType . User ? ClientBucket . Get ( clientBucket ) . Id : bucketId;
string json = payload ! = null ? SerializeJson ( payload ) : null ;
string json = payload ! = null ? SerializeJson ( payload ) : null ;
var request = new JsonRestRequest ( RestClient , method , endpoint , json , options ) ;
var request = new JsonRestRequest ( RestClient , method , endpoint , json , options ) ;
@ -215,7 +215,7 @@ namespace Discord.API
{
{
options = options ? ? new RequestOptions ( ) ;
options = options ? ? new RequestOptions ( ) ;
options . HeaderOnly = true ;
options . HeaderOnly = true ;
options . BucketId = bucketId;
options . BucketId = AuthTokenType = = TokenType . User ? ClientBucket . Get ( clientBucket ) . Id : bucketId;
var request = new MultipartRestRequest ( RestClient , method , endpoint , multipartArgs , options ) ;
var request = new MultipartRestRequest ( RestClient , method , endpoint , multipartArgs , options ) ;
await SendInternalAsync ( method , endpoint , request ) . ConfigureAwait ( false ) ;
await SendInternalAsync ( method , endpoint , request ) . ConfigureAwait ( false ) ;
@ -228,7 +228,7 @@ namespace Discord.API
string bucketId = null , ClientBucketType clientBucket = ClientBucketType . Unbucketed , RequestOptions options = null ) where TResponse : class
string bucketId = null , ClientBucketType clientBucket = ClientBucketType . Unbucketed , RequestOptions options = null ) where TResponse : class
{
{
options = options ? ? new RequestOptions ( ) ;
options = options ? ? new RequestOptions ( ) ;
options . BucketId = bucketId;
options . BucketId = AuthTokenType = = TokenType . User ? ClientBucket . Get ( clientBucket ) . Id : bucketId;
var request = new RestRequest ( RestClient , method , endpoint , options ) ;
var request = new RestRequest ( RestClient , method , endpoint , options ) ;
return DeserializeJson < TResponse > ( await SendInternalAsync ( method , endpoint , request ) . ConfigureAwait ( false ) ) ;
return DeserializeJson < TResponse > ( await SendInternalAsync ( method , endpoint , request ) . ConfigureAwait ( false ) ) ;
@ -241,7 +241,7 @@ namespace Discord.API
string bucketId = null , ClientBucketType clientBucket = ClientBucketType . Unbucketed , RequestOptions options = null ) where TResponse : class
string bucketId = null , ClientBucketType clientBucket = ClientBucketType . Unbucketed , RequestOptions options = null ) where TResponse : class
{
{
options = options ? ? new RequestOptions ( ) ;
options = options ? ? new RequestOptions ( ) ;
options . BucketId = bucketId;
options . BucketId = AuthTokenType = = TokenType . User ? ClientBucket . Get ( clientBucket ) . Id : bucketId;
string json = payload ! = null ? SerializeJson ( payload ) : null ;
string json = payload ! = null ? SerializeJson ( payload ) : null ;
var request = new JsonRestRequest ( RestClient , method , endpoint , json , options ) ;
var request = new JsonRestRequest ( RestClient , method , endpoint , json , options ) ;
@ -255,7 +255,8 @@ namespace Discord.API
string bucketId = null , ClientBucketType clientBucket = ClientBucketType . Unbucketed , RequestOptions options = null )
string bucketId = null , ClientBucketType clientBucket = ClientBucketType . Unbucketed , RequestOptions options = null )
{
{
options = options ? ? new RequestOptions ( ) ;
options = options ? ? new RequestOptions ( ) ;
options . BucketId = bucketId ;
options . BucketId = AuthTokenType = = TokenType . User ? ClientBucket . Get ( clientBucket ) . Id : bucketId ;
var request = new MultipartRestRequest ( RestClient , method , endpoint , multipartArgs , options ) ;
var request = new MultipartRestRequest ( RestClient , method , endpoint , multipartArgs , options ) ;
return DeserializeJson < TResponse > ( await SendInternalAsync ( method , endpoint , request ) . ConfigureAwait ( false ) ) ;
return DeserializeJson < TResponse > ( await SendInternalAsync ( method , endpoint , request ) . ConfigureAwait ( false ) ) ;