* GetRelationshipsAsync() * AddFriendAsync(ulong) * BlockUserAsync(ulong) * RemoveRelationshipAsync(ulong)pull/369/head
| @@ -47,16 +47,16 @@ Global | |||
| {496DB20A-A455-4D01-B6BC-90FE6D7C6B81}.Release|x86.Build.0 = Debug|Any CPU | |||
| {91E9E7BD-75C9-4E98-84AA-2C271922E5C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||
| {91E9E7BD-75C9-4E98-84AA-2C271922E5C2}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
| {91E9E7BD-75C9-4E98-84AA-2C271922E5C2}.Debug|x64.ActiveCfg = Debug|x64 | |||
| {91E9E7BD-75C9-4E98-84AA-2C271922E5C2}.Debug|x64.Build.0 = Debug|x64 | |||
| {91E9E7BD-75C9-4E98-84AA-2C271922E5C2}.Debug|x86.ActiveCfg = Debug|x86 | |||
| {91E9E7BD-75C9-4E98-84AA-2C271922E5C2}.Debug|x86.Build.0 = Debug|x86 | |||
| {91E9E7BD-75C9-4E98-84AA-2C271922E5C2}.Debug|x64.ActiveCfg = Debug|Any CPU | |||
| {91E9E7BD-75C9-4E98-84AA-2C271922E5C2}.Debug|x64.Build.0 = Debug|Any CPU | |||
| {91E9E7BD-75C9-4E98-84AA-2C271922E5C2}.Debug|x86.ActiveCfg = Debug|Any CPU | |||
| {91E9E7BD-75C9-4E98-84AA-2C271922E5C2}.Debug|x86.Build.0 = Debug|Any CPU | |||
| {91E9E7BD-75C9-4E98-84AA-2C271922E5C2}.Release|Any CPU.ActiveCfg = Debug|Any CPU | |||
| {91E9E7BD-75C9-4E98-84AA-2C271922E5C2}.Release|Any CPU.Build.0 = Debug|Any CPU | |||
| {91E9E7BD-75C9-4E98-84AA-2C271922E5C2}.Release|x64.ActiveCfg = Release|x64 | |||
| {91E9E7BD-75C9-4E98-84AA-2C271922E5C2}.Release|x64.Build.0 = Release|x64 | |||
| {91E9E7BD-75C9-4E98-84AA-2C271922E5C2}.Release|x86.ActiveCfg = Release|x86 | |||
| {91E9E7BD-75C9-4E98-84AA-2C271922E5C2}.Release|x86.Build.0 = Release|x86 | |||
| {91E9E7BD-75C9-4E98-84AA-2C271922E5C2}.Release|x64.ActiveCfg = Debug|Any CPU | |||
| {91E9E7BD-75C9-4E98-84AA-2C271922E5C2}.Release|x64.Build.0 = Debug|Any CPU | |||
| {91E9E7BD-75C9-4E98-84AA-2C271922E5C2}.Release|x86.ActiveCfg = Debug|Any CPU | |||
| {91E9E7BD-75C9-4E98-84AA-2C271922E5C2}.Release|x86.Build.0 = Debug|Any CPU | |||
| {BFC6DC28-0351-4573-926A-D4124244C04F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||
| {BFC6DC28-0351-4573-926A-D4124244C04F}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
| {BFC6DC28-0351-4573-926A-D4124244C04F}.Debug|x64.ActiveCfg = Debug|Any CPU | |||
| @@ -95,16 +95,16 @@ Global | |||
| {078DD7E6-943D-4D09-AFC2-D2BA58B76C9C}.Release|x86.Build.0 = Debug|Any CPU | |||
| {688FD1D8-7F01-4539-B2E9-F473C5D699C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||
| {688FD1D8-7F01-4539-B2E9-F473C5D699C7}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
| {688FD1D8-7F01-4539-B2E9-F473C5D699C7}.Debug|x64.ActiveCfg = Debug|x64 | |||
| {688FD1D8-7F01-4539-B2E9-F473C5D699C7}.Debug|x64.Build.0 = Debug|x64 | |||
| {688FD1D8-7F01-4539-B2E9-F473C5D699C7}.Debug|x86.ActiveCfg = Debug|x86 | |||
| {688FD1D8-7F01-4539-B2E9-F473C5D699C7}.Debug|x86.Build.0 = Debug|x86 | |||
| {688FD1D8-7F01-4539-B2E9-F473C5D699C7}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
| {688FD1D8-7F01-4539-B2E9-F473C5D699C7}.Release|Any CPU.Build.0 = Release|Any CPU | |||
| {688FD1D8-7F01-4539-B2E9-F473C5D699C7}.Release|x64.ActiveCfg = Release|x64 | |||
| {688FD1D8-7F01-4539-B2E9-F473C5D699C7}.Release|x64.Build.0 = Release|x64 | |||
| {688FD1D8-7F01-4539-B2E9-F473C5D699C7}.Release|x86.ActiveCfg = Release|x86 | |||
| {688FD1D8-7F01-4539-B2E9-F473C5D699C7}.Release|x86.Build.0 = Release|x86 | |||
| {688FD1D8-7F01-4539-B2E9-F473C5D699C7}.Debug|x64.ActiveCfg = Debug|Any CPU | |||
| {688FD1D8-7F01-4539-B2E9-F473C5D699C7}.Debug|x64.Build.0 = Debug|Any CPU | |||
| {688FD1D8-7F01-4539-B2E9-F473C5D699C7}.Debug|x86.ActiveCfg = Debug|Any CPU | |||
| {688FD1D8-7F01-4539-B2E9-F473C5D699C7}.Debug|x86.Build.0 = Debug|Any CPU | |||
| {688FD1D8-7F01-4539-B2E9-F473C5D699C7}.Release|Any CPU.ActiveCfg = Debug|Any CPU | |||
| {688FD1D8-7F01-4539-B2E9-F473C5D699C7}.Release|Any CPU.Build.0 = Debug|Any CPU | |||
| {688FD1D8-7F01-4539-B2E9-F473C5D699C7}.Release|x64.ActiveCfg = Debug|Any CPU | |||
| {688FD1D8-7F01-4539-B2E9-F473C5D699C7}.Release|x64.Build.0 = Debug|Any CPU | |||
| {688FD1D8-7F01-4539-B2E9-F473C5D699C7}.Release|x86.ActiveCfg = Debug|Any CPU | |||
| {688FD1D8-7F01-4539-B2E9-F473C5D699C7}.Release|x86.Build.0 = Debug|Any CPU | |||
| EndGlobalSection | |||
| GlobalSection(SolutionProperties) = preSolution | |||
| HideSolutionNode = FALSE | |||
| @@ -242,7 +242,7 @@ namespace Discord.API | |||
| 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) | |||
| => 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) | |||
| { | |||
| options = options ?? new RequestOptions(); | |||
| @@ -386,7 +386,7 @@ namespace Discord.API | |||
| break; | |||
| } | |||
| } | |||
| //Channel Messages | |||
| 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.RegionId, nameof(args.RegionId)); | |||
| options = RequestOptions.CreateOrClone(options); | |||
| return await SendJsonAsync<Guild>("POST", () => "guilds", args, new BucketIds(), options: options).ConfigureAwait(false); | |||
| } | |||
| public async Task<Guild> DeleteGuildAsync(ulong guildId, RequestOptions options = null) | |||
| @@ -830,14 +830,14 @@ namespace Discord.API | |||
| { | |||
| Preconditions.NotNullOrEmpty(inviteId, nameof(inviteId)); | |||
| options = RequestOptions.CreateOrClone(options); | |||
| return await SendAsync<Invite>("DELETE", () => $"invites/{inviteId}", new BucketIds(), options: options).ConfigureAwait(false); | |||
| } | |||
| public async Task AcceptInviteAsync(string inviteId, RequestOptions options = null) | |||
| { | |||
| Preconditions.NotNullOrEmpty(inviteId, nameof(inviteId)); | |||
| options = RequestOptions.CreateOrClone(options); | |||
| 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; } | |||
| } | |||
| //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 | |||
| 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)); | |||
| string fieldName = GetFieldName(methodArgs[argId + 1]); | |||
| int? mappedId; | |||
| mappedId = BucketIds.GetIndex(fieldName); | |||
| if(!mappedId.HasValue && rightIndex != endIndex && format.Length > rightIndex + 1 && format[rightIndex + 1] == '/') //Ignore the next slash | |||
| rightIndex++; | |||
| @@ -0,0 +1,11 @@ | |||
| using Newtonsoft.Json; | |||
| namespace Discord.API.Rest | |||
| { | |||
| [JsonObject(MemberSerialization = MemberSerialization.OptIn)] | |||
| public class BlockUserParams | |||
| { | |||
| [JsonProperty("type")] | |||
| public RelationshipType Type { get; } = RelationshipType.Blocked; | |||
| } | |||
| } | |||
| @@ -25,12 +25,17 @@ namespace Discord | |||
| Task<IGuild> GetGuildAsync(ulong id, CacheMode mode = CacheMode.AllowDownload); | |||
| Task<IReadOnlyCollection<IGuild>> GetGuildsAsync(CacheMode mode = CacheMode.AllowDownload); | |||
| Task<IGuild> CreateGuildAsync(string name, IVoiceRegion region, Stream jpegIcon = null); | |||
| Task<IInvite> GetInviteAsync(string inviteId); | |||
| Task<IUser> GetUserAsync(ulong id, CacheMode mode = CacheMode.AllowDownload); | |||
| Task<IUser> GetUserAsync(string username, string discriminator); | |||
| Task<IReadOnlyCollection<Relationship>> GetRelationshipsAsync(); | |||
| Task RemoveRelationshipAsync(ulong userId); | |||
| Task AddFriendAsync(ulong userId); | |||
| Task BlockUserAsync(ulong userId); | |||
| Task<IReadOnlyCollection<IVoiceRegion>> GetVoiceRegionsAsync(); | |||
| Task<IVoiceRegion> GetVoiceRegionAsync(string id); | |||
| } | |||
| @@ -124,6 +124,11 @@ namespace Discord.Rest | |||
| /// <inheritdoc /> | |||
| public void Dispose() => Dispose(true); | |||
| Task<IReadOnlyCollection<API.Relationship>> IDiscordClient.GetRelationshipsAsync() => ApiClient.GetRelationshipsAsync(); | |||
| Task IDiscordClient.AddFriendAsync(ulong userId) => ApiClient.AddFriendAsync(userId); | |||
| Task IDiscordClient.BlockUserAsync(ulong userId) => ApiClient.BlockUserAsync(userId); | |||
| Task IDiscordClient.RemoveRelationshipAsync(ulong userId) => ApiClient.RemoveRelationshipAsync(userId); | |||
| //IDiscordClient | |||
| ConnectionState IDiscordClient.ConnectionState => ConnectionState.Disconnected; | |||
| ISelfUser IDiscordClient.CurrentUser => CurrentUser; | |||