| @@ -128,5 +128,11 @@ namespace Discord.Rest | |||||
| var models = await client.ApiClient.GetVoiceRegionsAsync().ConfigureAwait(false); | var models = await client.ApiClient.GetVoiceRegionsAsync().ConfigureAwait(false); | ||||
| return models.Select(x => RestVoiceRegion.Create(client, x)).Where(x => x.Id == id).FirstOrDefault(); | return models.Select(x => RestVoiceRegion.Create(client, x)).Where(x => x.Id == id).FirstOrDefault(); | ||||
| } | } | ||||
| public static async Task<IReadOnlyCollection<RestRelationship>> GetRelationshipsAsync(BaseDiscordClient client) | |||||
| { | |||||
| var models = await client.ApiClient.GetRelationshipsAsync().ConfigureAwait(false); | |||||
| return models.Select(r => RestRelationship.Create(client, r)).ToImmutableArray(); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -89,6 +89,9 @@ namespace Discord.Rest | |||||
| public Task<RestVoiceRegion> GetVoiceRegionAsync(string id) | public Task<RestVoiceRegion> GetVoiceRegionAsync(string id) | ||||
| => ClientHelper.GetVoiceRegionAsync(this, id); | => ClientHelper.GetVoiceRegionAsync(this, id); | ||||
| public Task<IReadOnlyCollection<RestRelationship>> GetRelationshipsAsync() | |||||
| => ClientHelper.GetRelationshipsAsync(this); | |||||
| //IDiscordClient | //IDiscordClient | ||||
| async Task<IApplication> IDiscordClient.GetApplicationInfoAsync() | async Task<IApplication> IDiscordClient.GetApplicationInfoAsync() | ||||
| => await GetApplicationInfoAsync().ConfigureAwait(false); | => await GetApplicationInfoAsync().ConfigureAwait(false); | ||||
| @@ -0,0 +1,26 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| using Model = Discord.API.Relationship; | |||||
| namespace Discord.Rest | |||||
| { | |||||
| public class RestRelationship : IRelationship | |||||
| { | |||||
| public RelationshipType Type { get; internal set; } | |||||
| public IUser User { get; internal set; } | |||||
| internal RestRelationship(RelationshipType type, IUser user) | |||||
| { | |||||
| Type = type; | |||||
| User = user; | |||||
| } | |||||
| internal static RestRelationship Create(BaseDiscordClient discord, Model model) | |||||
| { | |||||
| RestUser user = RestUser.Create(discord, model.User); | |||||
| return new RestRelationship(model.Type, user); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -53,26 +53,18 @@ namespace Discord.Rest | |||||
| public override string ToString() => $"{Username}#{Discriminator}"; | public override string ToString() => $"{Username}#{Discriminator}"; | ||||
| private string DebuggerDisplay => $"{Username}#{Discriminator} ({Id}{(IsBot ? ", Bot" : "")})"; | private string DebuggerDisplay => $"{Username}#{Discriminator} ({Id}{(IsBot ? ", Bot" : "")})"; | ||||
| public Task AddFriendAsync(RequestOptions options = null) | |||||
| => Discord.ApiClient.AddFriendAsync(Id, options); | |||||
| public Task BlockUserAsync(RequestOptions options = null) | |||||
| => Discord.ApiClient.BlockUserAsync(Id, options); | |||||
| public Task RemoveRelationshipAsync(RequestOptions options = null) | |||||
| => Discord.ApiClient.RemoveRelationshipAsync(Id, options); | |||||
| //IUser | //IUser | ||||
| Task<IDMChannel> IUser.GetDMChannelAsync(CacheMode mode, RequestOptions options) | Task<IDMChannel> IUser.GetDMChannelAsync(CacheMode mode, RequestOptions options) | ||||
| => Task.FromResult<IDMChannel>(null); | => Task.FromResult<IDMChannel>(null); | ||||
| async Task<IDMChannel> IUser.CreateDMChannelAsync(RequestOptions options) | async Task<IDMChannel> IUser.CreateDMChannelAsync(RequestOptions options) | ||||
| => await CreateDMChannelAsync(options).ConfigureAwait(false); | => await CreateDMChannelAsync(options).ConfigureAwait(false); | ||||
| public Task AddFriendAsync(RequestOptions options = null) | |||||
| { | |||||
| throw new NotImplementedException(); | |||||
| } | |||||
| public Task BlockUserAsync(RequestOptions options = null) | |||||
| { | |||||
| throw new NotImplementedException(); | |||||
| } | |||||
| public Task RemoveRelationshipAsync(RequestOptions options = null) | |||||
| { | |||||
| throw new NotImplementedException(); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -55,19 +55,11 @@ namespace Discord.Rpc | |||||
| async Task<IDMChannel> IUser.CreateDMChannelAsync(RequestOptions options) | async Task<IDMChannel> IUser.CreateDMChannelAsync(RequestOptions options) | ||||
| => await CreateDMChannelAsync(options).ConfigureAwait(false); | => await CreateDMChannelAsync(options).ConfigureAwait(false); | ||||
| public Task AddFriendAsync(RequestOptions options = null) | |||||
| { | |||||
| throw new NotImplementedException(); | |||||
| } | |||||
| public Task BlockUserAsync(RequestOptions options = null) | |||||
| { | |||||
| throw new NotImplementedException(); | |||||
| } | |||||
| public Task RemoveRelationshipAsync(RequestOptions options = null) | |||||
| { | |||||
| throw new NotImplementedException(); | |||||
| } | |||||
| Task IUser.AddFriendAsync(RequestOptions options) | |||||
| => throw new NotSupportedException(); | |||||
| Task IUser.BlockUserAsync(RequestOptions options) | |||||
| => throw new NotSupportedException(); | |||||
| Task IUser.RemoveRelationshipAsync(RequestOptions options) | |||||
| => throw new NotSupportedException(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -272,6 +272,9 @@ namespace Discord.WebSocket | |||||
| public Task<RestInvite> GetInviteAsync(string inviteId) | public Task<RestInvite> GetInviteAsync(string inviteId) | ||||
| => ClientHelper.GetInviteAsync(this, inviteId); | => ClientHelper.GetInviteAsync(this, inviteId); | ||||
| public Task<IReadOnlyCollection<SocketRelationship>> GetRelationshipsAsync() | |||||
| => Task.FromResult(State.Relationships); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public SocketUser GetUser(ulong id) | public SocketUser GetUser(ulong id) | ||||
| { | { | ||||
| @@ -1730,5 +1733,8 @@ namespace Discord.WebSocket | |||||
| => await StartAsync().ConfigureAwait(false); | => await StartAsync().ConfigureAwait(false); | ||||
| async Task IDiscordClient.StopAsync() | async Task IDiscordClient.StopAsync() | ||||
| => await StopAsync().ConfigureAwait(false); | => await StopAsync().ConfigureAwait(false); | ||||
| async Task<IReadOnlyCollection<IRelationship>> IDiscordClient.GetRelationshipsAsync() | |||||
| => await GetRelationshipsAsync(); | |||||
| } | } | ||||
| } | } | ||||