diff --git a/src/Discord.Net.Core/Entities/Users/IUser.cs b/src/Discord.Net.Core/Entities/Users/IUser.cs index 3f8f33012..5b0726d25 100644 --- a/src/Discord.Net.Core/Entities/Users/IUser.cs +++ b/src/Discord.Net.Core/Entities/Users/IUser.cs @@ -18,11 +18,6 @@ namespace Discord bool IsWebhook { get; } /// Gets the username for this user. string Username { get; } - - /// Returns a private message channel to this user, creating one if it does not already exist. - Task GetDMChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); - /// Returns a private message channel to this user, creating one if it does not already exist. - Task CreateDMChannelAsync(RequestOptions options = null); /// Adds this user as a friend, this will remove a block Task AddFriendAsync(RequestOptions options = null); @@ -30,6 +25,7 @@ namespace Discord Task BlockUserAsync(RequestOptions options = null); /// Removes the relationship of this user Task RemoveRelationshipAsync(RequestOptions options = null); + /// Returns a private message channel to this user, creating one if it does not already exist. Task GetOrCreateDMChannelAsync(RequestOptions options = null); } } diff --git a/src/Discord.Net.Core/IDiscordClient.cs b/src/Discord.Net.Core/IDiscordClient.cs index 23e8e9c5b..aa4a40013 100644 --- a/src/Discord.Net.Core/IDiscordClient.cs +++ b/src/Discord.Net.Core/IDiscordClient.cs @@ -26,6 +26,8 @@ namespace Discord Task GetGuildAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); Task> GetGuildsAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); Task CreateGuildAsync(string name, IVoiceRegion region, Stream jpegIcon = null, RequestOptions options = null); + + Task> GetRelationshipsAsync(RequestOptions options = null); Task GetInviteAsync(string inviteId, RequestOptions options = null); diff --git a/src/Discord.Net.Rest/BaseDiscordClient.cs b/src/Discord.Net.Rest/BaseDiscordClient.cs index 6239a2eb9..a3bbd5d49 100644 --- a/src/Discord.Net.Rest/BaseDiscordClient.cs +++ b/src/Discord.Net.Rest/BaseDiscordClient.cs @@ -127,10 +127,10 @@ namespace Discord.Rest ConnectionState IDiscordClient.ConnectionState => ConnectionState.Disconnected; ISelfUser IDiscordClient.CurrentUser => CurrentUser; - Task> IDiscordClient.GetRelationshipsAsync() + Task> IDiscordClient.GetRelationshipsAsync(RequestOptions options) => Task.FromResult>(null); - Task IDiscordClient.GetApplicationInfoAsync() { throw new NotSupportedException(); } + Task IDiscordClient.GetApplicationInfoAsync(RequestOptions options) { throw new NotSupportedException(); } Task IDiscordClient.GetChannelAsync(ulong id, CacheMode mode, RequestOptions options) => Task.FromResult(null); diff --git a/src/Discord.Net.Rpc/Entities/Users/RpcUser.cs b/src/Discord.Net.Rpc/Entities/Users/RpcUser.cs index b30ba678f..e7bd8b614 100644 --- a/src/Discord.Net.Rpc/Entities/Users/RpcUser.cs +++ b/src/Discord.Net.Rpc/Entities/Users/RpcUser.cs @@ -58,17 +58,14 @@ namespace Discord.Rpc public override string ToString() => $"{Username}#{Discriminator}"; private string DebuggerDisplay => $"{Username}#{Discriminator} ({Id}{(IsBot ? ", Bot" : "")})"; - //IUser - Task IUser.GetDMChannelAsync(CacheMode mode, RequestOptions options) - => Task.FromResult(null); - async Task IUser.CreateDMChannelAsync(RequestOptions options) - => await CreateDMChannelAsync(options).ConfigureAwait(false); - Task IUser.AddFriendAsync(RequestOptions options) => throw new NotSupportedException(); Task IUser.BlockUserAsync(RequestOptions options) => throw new NotSupportedException(); Task IUser.RemoveRelationshipAsync(RequestOptions options) => throw new NotSupportedException(); + + async Task IUser.GetOrCreateDMChannelAsync(RequestOptions options) + => await GetOrCreateDMChannelAsync(options); } } diff --git a/src/Discord.Net.WebSocket/DiscordSocketClient.cs b/src/Discord.Net.WebSocket/DiscordSocketClient.cs index 9b5da78e5..809340478 100644 --- a/src/Discord.Net.WebSocket/DiscordSocketClient.cs +++ b/src/Discord.Net.WebSocket/DiscordSocketClient.cs @@ -257,8 +257,8 @@ namespace Discord.WebSocket => ClientHelper.GetConnectionsAsync(this, new RequestOptions()); /// - public Task GetInviteAsync(string inviteId) - => ClientHelper.GetInviteAsync(this, inviteId); + public Task GetInviteAsync(string inviteId, RequestOptions options = null) + => ClientHelper.GetInviteAsync(this, inviteId, options); public Task> GetRelationshipsAsync() => Task.FromResult(State.Relationships); @@ -1842,6 +1842,8 @@ namespace Discord.WebSocket return State.RemoveRelationship(id); } + internal int GetAudioId() => _nextAudioId++; + //IDiscordClient async Task IDiscordClient.GetApplicationInfoAsync(RequestOptions options) => await GetApplicationInfoAsync().ConfigureAwait(false); @@ -1883,7 +1885,7 @@ namespace Discord.WebSocket async Task IDiscordClient.StopAsync() => await StopAsync().ConfigureAwait(false); - async Task> IDiscordClient.GetRelationshipsAsync() + async Task> IDiscordClient.GetRelationshipsAsync(RequestOptions options) => await GetRelationshipsAsync(); } } diff --git a/src/Discord.Net.WebSocket/Entities/Users/SocketRelationship.cs b/src/Discord.Net.WebSocket/Entities/Users/SocketRelationship.cs index a7bbcb805..b93326651 100644 --- a/src/Discord.Net.WebSocket/Entities/Users/SocketRelationship.cs +++ b/src/Discord.Net.WebSocket/Entities/Users/SocketRelationship.cs @@ -8,16 +8,18 @@ namespace Discord.WebSocket public IUser User { get; internal set; } - public SocketRelationship(RelationshipType type, IUser user) + internal SocketRelationship() { - Type = type; - User = user; } internal static SocketRelationship Create(DiscordSocketClient discord, ClientState state, Model model) { - SocketSimpleUser user = SocketSimpleUser.Create(discord, state, model.User); - return new SocketRelationship(model.Type, user); + SocketGlobalUser user = SocketGlobalUser.Create(discord, state, model.User); + return new SocketRelationship + { + Type = model.Type, + User = user + }; } } } diff --git a/src/Discord.Net.WebSocket/Entities/Users/SocketUser.cs b/src/Discord.Net.WebSocket/Entities/Users/SocketUser.cs index a31e2a90b..b3c126079 100644 --- a/src/Discord.Net.WebSocket/Entities/Users/SocketUser.cs +++ b/src/Discord.Net.WebSocket/Entities/Users/SocketUser.cs @@ -65,12 +65,6 @@ namespace Discord.WebSocket public override string ToString() => $"{Username}#{Discriminator}"; private string DebuggerDisplay => $"{Username}#{Discriminator} ({Id}{(IsBot ? ", Bot" : "")})"; internal SocketUser Clone() => MemberwiseClone() as SocketUser; - - //IUser - Task IUser.GetDMChannelAsync(CacheMode mode, RequestOptions options) - => Task.FromResult(GlobalUser.DMChannel); - async Task IUser.CreateDMChannelAsync(RequestOptions options) - => await CreateDMChannelAsync(options).ConfigureAwait(false); public async Task AddFriendAsync(RequestOptions options = null) => await Discord.ApiClient.AddFriendAsync(Id, options);