|
@@ -242,7 +242,7 @@ namespace Discord.API |
|
|
internal Task<TResponse> SendMultipartAsync<TResponse>(string method, Expression<Func<string>> endpointExpr, IReadOnlyDictionary<string, object> multipartArgs, BucketIds ids, |
|
|
internal Task<TResponse> SendMultipartAsync<TResponse>(string method, Expression<Func<string>> endpointExpr, IReadOnlyDictionary<string, object> multipartArgs, BucketIds ids, |
|
|
ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null, [CallerMemberName] string funcName = null) |
|
|
ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null, [CallerMemberName] string funcName = null) |
|
|
=> SendMultipartAsync<TResponse>(method, GetEndpoint(endpointExpr), multipartArgs, GetBucketId(ids, endpointExpr, AuthTokenType, funcName), clientBucket, options); |
|
|
=> 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, |
|
|
|
|
|
|
|
|
public async Task<TResponse> SendMultipartAsync<TResponse>(string method, string endpoint, IReadOnlyDictionary<string, object> multipartArgs, |
|
|
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(); |
|
@@ -386,7 +386,7 @@ namespace Discord.API |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Channel Messages |
|
|
//Channel Messages |
|
|
public async Task<Message> GetChannelMessageAsync(ulong channelId, ulong messageId, RequestOptions options = null) |
|
|
public async Task<Message> GetChannelMessageAsync(ulong channelId, ulong messageId, RequestOptions options = null) |
|
|
{ |
|
|
{ |
|
@@ -622,7 +622,7 @@ namespace Discord.API |
|
|
Preconditions.NotNullOrWhitespace(args.Name, nameof(args.Name)); |
|
|
Preconditions.NotNullOrWhitespace(args.Name, nameof(args.Name)); |
|
|
Preconditions.NotNullOrWhitespace(args.RegionId, nameof(args.RegionId)); |
|
|
Preconditions.NotNullOrWhitespace(args.RegionId, nameof(args.RegionId)); |
|
|
options = RequestOptions.CreateOrClone(options); |
|
|
options = RequestOptions.CreateOrClone(options); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return await SendJsonAsync<Guild>("POST", () => "guilds", args, new BucketIds(), options: options).ConfigureAwait(false); |
|
|
return await SendJsonAsync<Guild>("POST", () => "guilds", args, new BucketIds(), options: options).ConfigureAwait(false); |
|
|
} |
|
|
} |
|
|
public async Task<Guild> DeleteGuildAsync(ulong guildId, RequestOptions options = null) |
|
|
public async Task<Guild> DeleteGuildAsync(ulong guildId, RequestOptions options = null) |
|
@@ -830,14 +830,14 @@ namespace Discord.API |
|
|
{ |
|
|
{ |
|
|
Preconditions.NotNullOrEmpty(inviteId, nameof(inviteId)); |
|
|
Preconditions.NotNullOrEmpty(inviteId, nameof(inviteId)); |
|
|
options = RequestOptions.CreateOrClone(options); |
|
|
options = RequestOptions.CreateOrClone(options); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return await SendAsync<Invite>("DELETE", () => $"invites/{inviteId}", new BucketIds(), options: options).ConfigureAwait(false); |
|
|
return await SendAsync<Invite>("DELETE", () => $"invites/{inviteId}", new BucketIds(), options: options).ConfigureAwait(false); |
|
|
} |
|
|
} |
|
|
public async Task AcceptInviteAsync(string inviteId, RequestOptions options = null) |
|
|
public async Task AcceptInviteAsync(string inviteId, RequestOptions options = null) |
|
|
{ |
|
|
{ |
|
|
Preconditions.NotNullOrEmpty(inviteId, nameof(inviteId)); |
|
|
Preconditions.NotNullOrEmpty(inviteId, nameof(inviteId)); |
|
|
options = RequestOptions.CreateOrClone(options); |
|
|
options = RequestOptions.CreateOrClone(options); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await SendAsync("POST", () => $"invites/{inviteId}", new BucketIds(), options: options).ConfigureAwait(false); |
|
|
await SendAsync("POST", () => $"invites/{inviteId}", new BucketIds(), options: options).ConfigureAwait(false); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -972,6 +972,34 @@ namespace Discord.API |
|
|
} |
|
|
} |
|
|
catch (HttpException ex) when (ex.StatusCode == HttpStatusCode.NotFound) { return null; } |
|
|
catch (HttpException ex) when (ex.StatusCode == HttpStatusCode.NotFound) { return null; } |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Relationships |
|
|
|
|
|
public async Task<IReadOnlyCollection<Relationship>> GetRelationshipsAsync(RequestOptions options = null) |
|
|
|
|
|
{ |
|
|
|
|
|
options = RequestOptions.CreateOrClone(options); |
|
|
|
|
|
return await SendAsync<IReadOnlyCollection<Relationship>>("GET", () => "users/@me/relationships", new BucketIds(), options: options).ConfigureAwait(false); |
|
|
|
|
|
} |
|
|
|
|
|
public async Task AddFriendAsync(ulong userId, RequestOptions options = null) |
|
|
|
|
|
{ |
|
|
|
|
|
Preconditions.NotEqual(userId, 0, nameof(userId)); |
|
|
|
|
|
options = RequestOptions.CreateOrClone(options); |
|
|
|
|
|
|
|
|
|
|
|
await SendJsonAsync("PUT", () => $"users/@me/relationships/{userId}", new object(), new BucketIds(), options: options).ConfigureAwait(false); |
|
|
|
|
|
} |
|
|
|
|
|
public async Task BlockUserAsync(ulong userId, RequestOptions options = null) |
|
|
|
|
|
{ |
|
|
|
|
|
Preconditions.NotEqual(userId, 0, nameof(userId)); |
|
|
|
|
|
options = RequestOptions.CreateOrClone(options); |
|
|
|
|
|
|
|
|
|
|
|
await SendJsonAsync("PUT", () => $"users/@me/relationships/{userId}", new BlockUserParams(), new BucketIds(), options: options).ConfigureAwait(false); |
|
|
|
|
|
} |
|
|
|
|
|
public async Task RemoveRelationshipAsync(ulong userId, RequestOptions options = null) |
|
|
|
|
|
{ |
|
|
|
|
|
Preconditions.NotEqual(userId, 0, nameof(userId)); |
|
|
|
|
|
options = RequestOptions.CreateOrClone(options); |
|
|
|
|
|
|
|
|
|
|
|
await SendAsync("DELETE", () => $"users/@me/relationships/{userId}", new BucketIds(), options: options).ConfigureAwait(false); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//Current User/DMs |
|
|
//Current User/DMs |
|
|
public async Task<User> GetMyUserAsync(RequestOptions options = null) |
|
|
public async Task<User> GetMyUserAsync(RequestOptions options = null) |
|
@@ -1137,7 +1165,7 @@ namespace Discord.API |
|
|
int argId = int.Parse(format.Substring(leftIndex + 1, rightIndex - leftIndex - 1)); |
|
|
int argId = int.Parse(format.Substring(leftIndex + 1, rightIndex - leftIndex - 1)); |
|
|
string fieldName = GetFieldName(methodArgs[argId + 1]); |
|
|
string fieldName = GetFieldName(methodArgs[argId + 1]); |
|
|
int? mappedId; |
|
|
int? mappedId; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mappedId = BucketIds.GetIndex(fieldName); |
|
|
mappedId = BucketIds.GetIndex(fieldName); |
|
|
if(!mappedId.HasValue && rightIndex != endIndex && format.Length > rightIndex + 1 && format[rightIndex + 1] == '/') //Ignore the next slash |
|
|
if(!mappedId.HasValue && rightIndex != endIndex && format.Length > rightIndex + 1 && format[rightIndex + 1] == '/') //Ignore the next slash |
|
|
rightIndex++; |
|
|
rightIndex++; |
|
|