|
|
@@ -165,14 +165,14 @@ namespace Discord.API |
|
|
|
|
|
|
|
//Core |
|
|
|
internal Task SendAsync(string method, Expression<Func<string>> endpointExpr, BucketIds ids, |
|
|
|
string clientBucketId = null, RequestOptions options = null, [CallerMemberName] string funcName = null) |
|
|
|
=> SendAsync(method, GetEndpoint(endpointExpr), GetBucketId(ids, endpointExpr, AuthTokenType, funcName), clientBucketId, options); |
|
|
|
ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null, [CallerMemberName] string funcName = null) |
|
|
|
=> SendAsync(method, GetEndpoint(endpointExpr), GetBucketId(ids, endpointExpr, AuthTokenType, funcName), clientBucket, options); |
|
|
|
public async Task SendAsync(string method, string endpoint, |
|
|
|
string bucketId = null, string clientBucketId = null, RequestOptions options = null) |
|
|
|
string bucketId = null, ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null) |
|
|
|
{ |
|
|
|
options = options ?? new RequestOptions(); |
|
|
|
options.HeaderOnly = true; |
|
|
|
options.BucketId = AuthTokenType == TokenType.User ? clientBucketId : bucketId; |
|
|
|
options.BucketId = AuthTokenType == TokenType.User ? ClientBucket.Get(clientBucket).Id : bucketId; |
|
|
|
options.IsClientBucket = AuthTokenType == TokenType.User; |
|
|
|
|
|
|
|
var request = new RestRequest(_restClient, method, endpoint, options); |
|
|
@@ -180,14 +180,14 @@ namespace Discord.API |
|
|
|
} |
|
|
|
|
|
|
|
internal Task SendJsonAsync(string method, Expression<Func<string>> endpointExpr, object payload, BucketIds ids, |
|
|
|
string clientBucketId = null, RequestOptions options = null, [CallerMemberName] string funcName = null) |
|
|
|
=> SendJsonAsync(method, GetEndpoint(endpointExpr), payload, GetBucketId(ids, endpointExpr, AuthTokenType, funcName), clientBucketId, options); |
|
|
|
ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null, [CallerMemberName] string funcName = null) |
|
|
|
=> SendJsonAsync(method, GetEndpoint(endpointExpr), payload, GetBucketId(ids, endpointExpr, AuthTokenType, funcName), clientBucket, options); |
|
|
|
public async Task SendJsonAsync(string method, string endpoint, object payload, |
|
|
|
string bucketId = null, string clientBucketId = null, RequestOptions options = null) |
|
|
|
string bucketId = null, ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null) |
|
|
|
{ |
|
|
|
options = options ?? new RequestOptions(); |
|
|
|
options.HeaderOnly = true; |
|
|
|
options.BucketId = AuthTokenType == TokenType.User ? clientBucketId : bucketId; |
|
|
|
options.BucketId = AuthTokenType == TokenType.User ? ClientBucket.Get(clientBucket).Id : bucketId; |
|
|
|
options.IsClientBucket = AuthTokenType == TokenType.User; |
|
|
|
|
|
|
|
var json = payload != null ? SerializeJson(payload) : null; |
|
|
@@ -196,14 +196,14 @@ namespace Discord.API |
|
|
|
} |
|
|
|
|
|
|
|
internal Task SendMultipartAsync(string method, Expression<Func<string>> endpointExpr, IReadOnlyDictionary<string, object> multipartArgs, BucketIds ids, |
|
|
|
string clientBucketId = null, RequestOptions options = null, [CallerMemberName] string funcName = null) |
|
|
|
=> SendMultipartAsync(method, GetEndpoint(endpointExpr), multipartArgs, GetBucketId(ids, endpointExpr, AuthTokenType, funcName), clientBucketId, options); |
|
|
|
ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null, [CallerMemberName] string funcName = null) |
|
|
|
=> SendMultipartAsync(method, GetEndpoint(endpointExpr), multipartArgs, GetBucketId(ids, endpointExpr, AuthTokenType, funcName), clientBucket, options); |
|
|
|
public async Task SendMultipartAsync(string method, string endpoint, IReadOnlyDictionary<string, object> multipartArgs, |
|
|
|
string bucketId = null, string clientBucketId = null, RequestOptions options = null) |
|
|
|
string bucketId = null, ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null) |
|
|
|
{ |
|
|
|
options = options ?? new RequestOptions(); |
|
|
|
options.HeaderOnly = true; |
|
|
|
options.BucketId = AuthTokenType == TokenType.User ? clientBucketId : bucketId; |
|
|
|
options.BucketId = AuthTokenType == TokenType.User ? ClientBucket.Get(clientBucket).Id : bucketId; |
|
|
|
options.IsClientBucket = AuthTokenType == TokenType.User; |
|
|
|
|
|
|
|
var request = new MultipartRestRequest(_restClient, method, endpoint, multipartArgs, options); |
|
|
@@ -211,13 +211,13 @@ namespace Discord.API |
|
|
|
} |
|
|
|
|
|
|
|
internal Task<TResponse> SendAsync<TResponse>(string method, Expression<Func<string>> endpointExpr, BucketIds ids, |
|
|
|
string clientBucketId = null, RequestOptions options = null, [CallerMemberName] string funcName = null) where TResponse : class |
|
|
|
=> SendAsync<TResponse>(method, GetEndpoint(endpointExpr), GetBucketId(ids, endpointExpr, AuthTokenType, funcName), clientBucketId, options); |
|
|
|
ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null, [CallerMemberName] string funcName = null) where TResponse : class |
|
|
|
=> SendAsync<TResponse>(method, GetEndpoint(endpointExpr), GetBucketId(ids, endpointExpr, AuthTokenType, funcName), clientBucket, options); |
|
|
|
public async Task<TResponse> SendAsync<TResponse>(string method, string endpoint, |
|
|
|
string bucketId = null, string clientBucketId = null, RequestOptions options = null) where TResponse : class |
|
|
|
string bucketId = null, ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null) where TResponse : class |
|
|
|
{ |
|
|
|
options = options ?? new RequestOptions(); |
|
|
|
options.BucketId = AuthTokenType == TokenType.User ? clientBucketId : bucketId; |
|
|
|
options.BucketId = AuthTokenType == TokenType.User ? ClientBucket.Get(clientBucket).Id : bucketId; |
|
|
|
options.IsClientBucket = AuthTokenType == TokenType.User; |
|
|
|
|
|
|
|
var request = new RestRequest(_restClient, method, endpoint, options); |
|
|
@@ -225,13 +225,13 @@ namespace Discord.API |
|
|
|
} |
|
|
|
|
|
|
|
internal Task<TResponse> SendJsonAsync<TResponse>(string method, Expression<Func<string>> endpointExpr, object payload, BucketIds ids, |
|
|
|
string clientBucketId = null, RequestOptions options = null, [CallerMemberName] string funcName = null) where TResponse : class |
|
|
|
=> SendJsonAsync<TResponse>(method, GetEndpoint(endpointExpr), payload, GetBucketId(ids, endpointExpr, AuthTokenType, funcName), clientBucketId, options); |
|
|
|
ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null, [CallerMemberName] string funcName = null) where TResponse : class |
|
|
|
=> SendJsonAsync<TResponse>(method, GetEndpoint(endpointExpr), payload, GetBucketId(ids, endpointExpr, AuthTokenType, funcName), clientBucket, options); |
|
|
|
public async Task<TResponse> SendJsonAsync<TResponse>(string method, string endpoint, object payload, |
|
|
|
string bucketId = null, string clientBucketId = null, RequestOptions options = null) where TResponse : class |
|
|
|
string bucketId = null, ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null) where TResponse : class |
|
|
|
{ |
|
|
|
options = options ?? new RequestOptions(); |
|
|
|
options.BucketId = AuthTokenType == TokenType.User ? clientBucketId : bucketId; |
|
|
|
options.BucketId = AuthTokenType == TokenType.User ? ClientBucket.Get(clientBucket).Id : bucketId; |
|
|
|
options.IsClientBucket = AuthTokenType == TokenType.User; |
|
|
|
|
|
|
|
var json = payload != null ? SerializeJson(payload) : null; |
|
|
@@ -240,13 +240,13 @@ namespace Discord.API |
|
|
|
} |
|
|
|
|
|
|
|
internal Task<TResponse> SendMultipartAsync<TResponse>(string method, Expression<Func<string>> endpointExpr, IReadOnlyDictionary<string, object> multipartArgs, BucketIds ids, |
|
|
|
string clientBucketId = null, RequestOptions options = null, [CallerMemberName] string funcName = null) |
|
|
|
=> SendMultipartAsync<TResponse>(method, GetEndpoint(endpointExpr), multipartArgs, GetBucketId(ids, endpointExpr, AuthTokenType, funcName), clientBucketId, options); |
|
|
|
ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null, [CallerMemberName] string funcName = null) |
|
|
|
=> SendMultipartAsync<TResponse>(method, GetEndpoint(endpointExpr), multipartArgs, GetBucketId(ids, endpointExpr, AuthTokenType, funcName), clientBucket, options); |
|
|
|
public async Task<TResponse> SendMultipartAsync<TResponse>(string method, string endpoint, IReadOnlyDictionary<string, object> multipartArgs, |
|
|
|
string bucketId = null, string clientBucketId = null, RequestOptions options = null) |
|
|
|
string bucketId = null, ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null) |
|
|
|
{ |
|
|
|
options = options ?? new RequestOptions(); |
|
|
|
options.BucketId = AuthTokenType == TokenType.User ? clientBucketId : bucketId; |
|
|
|
options.BucketId = AuthTokenType == TokenType.User ? ClientBucket.Get(clientBucket).Id : bucketId; |
|
|
|
options.IsClientBucket = AuthTokenType == TokenType.User; |
|
|
|
|
|
|
|
var request = new MultipartRestRequest(_restClient, method, endpoint, multipartArgs, options); |
|
|
@@ -445,7 +445,7 @@ namespace Discord.API |
|
|
|
options = RequestOptions.CreateOrClone(options); |
|
|
|
|
|
|
|
var ids = new BucketIds(channelId: channelId); |
|
|
|
return await SendJsonAsync<Message>("POST", () => $"channels/{channelId}/messages", args, ids, clientBucketId: ClientBucket.SendEditId, options: options).ConfigureAwait(false); |
|
|
|
return await SendJsonAsync<Message>("POST", () => $"channels/{channelId}/messages", args, ids, clientBucket: ClientBucketType.SendEdit, options: options).ConfigureAwait(false); |
|
|
|
} |
|
|
|
public async Task<Message> UploadFileAsync(ulong channelId, UploadFileParams args, RequestOptions options = null) |
|
|
|
{ |
|
|
@@ -464,7 +464,7 @@ namespace Discord.API |
|
|
|
} |
|
|
|
|
|
|
|
var ids = new BucketIds(channelId: channelId); |
|
|
|
return await SendMultipartAsync<Message>("POST", () => $"channels/{channelId}/messages", args.ToDictionary(), ids, clientBucketId: ClientBucket.SendEditId, options: options).ConfigureAwait(false); |
|
|
|
return await SendMultipartAsync<Message>("POST", () => $"channels/{channelId}/messages", args.ToDictionary(), ids, clientBucket: ClientBucketType.SendEdit, options: options).ConfigureAwait(false); |
|
|
|
} |
|
|
|
public async Task DeleteMessageAsync(ulong channelId, ulong messageId, RequestOptions options = null) |
|
|
|
{ |
|
|
@@ -510,7 +510,7 @@ namespace Discord.API |
|
|
|
options = RequestOptions.CreateOrClone(options); |
|
|
|
|
|
|
|
var ids = new BucketIds(channelId: channelId); |
|
|
|
return await SendJsonAsync<Message>("PATCH", () => $"channels/{channelId}/messages/{messageId}", args, ids, clientBucketId: ClientBucket.SendEditId, options: options).ConfigureAwait(false); |
|
|
|
return await SendJsonAsync<Message>("PATCH", () => $"channels/{channelId}/messages/{messageId}", args, ids, clientBucket: ClientBucketType.SendEdit, options: options).ConfigureAwait(false); |
|
|
|
} |
|
|
|
public async Task AckMessageAsync(ulong channelId, ulong messageId, RequestOptions options = null) |
|
|
|
{ |
|
|
|