@@ -18,11 +18,6 @@ namespace Discord | |||||
bool IsWebhook { get; } | bool IsWebhook { get; } | ||||
/// <summary> Gets the username for this user. </summary> | /// <summary> Gets the username for this user. </summary> | ||||
string Username { get; } | string Username { get; } | ||||
/// <summary> Returns a private message channel to this user, creating one if it does not already exist. </summary> | |||||
Task<IDMChannel> GetDMChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | |||||
/// <summary> Returns a private message channel to this user, creating one if it does not already exist. </summary> | |||||
Task<IDMChannel> CreateDMChannelAsync(RequestOptions options = null); | |||||
/// <summary> Adds this user as a friend, this will remove a block </summary> | /// <summary> Adds this user as a friend, this will remove a block </summary> | ||||
Task AddFriendAsync(RequestOptions options = null); | Task AddFriendAsync(RequestOptions options = null); | ||||
@@ -30,6 +25,7 @@ namespace Discord | |||||
Task BlockUserAsync(RequestOptions options = null); | Task BlockUserAsync(RequestOptions options = null); | ||||
/// <summary> Removes the relationship of this user </summary> | /// <summary> Removes the relationship of this user </summary> | ||||
Task RemoveRelationshipAsync(RequestOptions options = null); | Task RemoveRelationshipAsync(RequestOptions options = null); | ||||
/// <summary> Returns a private message channel to this user, creating one if it does not already exist. </summary> | |||||
Task<IDMChannel> GetOrCreateDMChannelAsync(RequestOptions options = null); | Task<IDMChannel> GetOrCreateDMChannelAsync(RequestOptions options = null); | ||||
} | } | ||||
} | } |
@@ -26,6 +26,8 @@ namespace Discord | |||||
Task<IGuild> GetGuildAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | Task<IGuild> GetGuildAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | ||||
Task<IReadOnlyCollection<IGuild>> GetGuildsAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | Task<IReadOnlyCollection<IGuild>> GetGuildsAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | ||||
Task<IGuild> CreateGuildAsync(string name, IVoiceRegion region, Stream jpegIcon = null, RequestOptions options = null); | Task<IGuild> CreateGuildAsync(string name, IVoiceRegion region, Stream jpegIcon = null, RequestOptions options = null); | ||||
Task<IReadOnlyCollection<IRelationship>> GetRelationshipsAsync(RequestOptions options = null); | |||||
Task<IInvite> GetInviteAsync(string inviteId, RequestOptions options = null); | Task<IInvite> GetInviteAsync(string inviteId, RequestOptions options = null); | ||||
@@ -127,10 +127,10 @@ namespace Discord.Rest | |||||
ConnectionState IDiscordClient.ConnectionState => ConnectionState.Disconnected; | ConnectionState IDiscordClient.ConnectionState => ConnectionState.Disconnected; | ||||
ISelfUser IDiscordClient.CurrentUser => CurrentUser; | ISelfUser IDiscordClient.CurrentUser => CurrentUser; | ||||
Task<IReadOnlyCollection<IRelationship>> IDiscordClient.GetRelationshipsAsync() | |||||
Task<IReadOnlyCollection<IRelationship>> IDiscordClient.GetRelationshipsAsync(RequestOptions options) | |||||
=> Task.FromResult<IReadOnlyCollection<IRelationship>>(null); | => Task.FromResult<IReadOnlyCollection<IRelationship>>(null); | ||||
Task<IApplication> IDiscordClient.GetApplicationInfoAsync() { throw new NotSupportedException(); } | |||||
Task<IApplication> IDiscordClient.GetApplicationInfoAsync(RequestOptions options) { throw new NotSupportedException(); } | |||||
Task<IChannel> IDiscordClient.GetChannelAsync(ulong id, CacheMode mode, RequestOptions options) | Task<IChannel> IDiscordClient.GetChannelAsync(ulong id, CacheMode mode, RequestOptions options) | ||||
=> Task.FromResult<IChannel>(null); | => Task.FromResult<IChannel>(null); | ||||
@@ -58,17 +58,14 @@ namespace Discord.Rpc | |||||
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" : "")})"; | ||||
//IUser | |||||
Task<IDMChannel> IUser.GetDMChannelAsync(CacheMode mode, RequestOptions options) | |||||
=> Task.FromResult<IDMChannel>(null); | |||||
async Task<IDMChannel> IUser.CreateDMChannelAsync(RequestOptions options) | |||||
=> await CreateDMChannelAsync(options).ConfigureAwait(false); | |||||
Task IUser.AddFriendAsync(RequestOptions options) | Task IUser.AddFriendAsync(RequestOptions options) | ||||
=> throw new NotSupportedException(); | => throw new NotSupportedException(); | ||||
Task IUser.BlockUserAsync(RequestOptions options) | Task IUser.BlockUserAsync(RequestOptions options) | ||||
=> throw new NotSupportedException(); | => throw new NotSupportedException(); | ||||
Task IUser.RemoveRelationshipAsync(RequestOptions options) | Task IUser.RemoveRelationshipAsync(RequestOptions options) | ||||
=> throw new NotSupportedException(); | => throw new NotSupportedException(); | ||||
async Task<IDMChannel> IUser.GetOrCreateDMChannelAsync(RequestOptions options) | |||||
=> await GetOrCreateDMChannelAsync(options); | |||||
} | } | ||||
} | } |
@@ -257,8 +257,8 @@ namespace Discord.WebSocket | |||||
=> ClientHelper.GetConnectionsAsync(this, new RequestOptions()); | => ClientHelper.GetConnectionsAsync(this, new RequestOptions()); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public Task<RestInvite> GetInviteAsync(string inviteId) | |||||
=> ClientHelper.GetInviteAsync(this, inviteId); | |||||
public Task<RestInvite> GetInviteAsync(string inviteId, RequestOptions options = null) | |||||
=> ClientHelper.GetInviteAsync(this, inviteId, options); | |||||
public Task<IReadOnlyCollection<SocketRelationship>> GetRelationshipsAsync() | public Task<IReadOnlyCollection<SocketRelationship>> GetRelationshipsAsync() | ||||
=> Task.FromResult(State.Relationships); | => Task.FromResult(State.Relationships); | ||||
@@ -1842,6 +1842,8 @@ namespace Discord.WebSocket | |||||
return State.RemoveRelationship(id); | return State.RemoveRelationship(id); | ||||
} | } | ||||
internal int GetAudioId() => _nextAudioId++; | |||||
//IDiscordClient | //IDiscordClient | ||||
async Task<IApplication> IDiscordClient.GetApplicationInfoAsync(RequestOptions options) | async Task<IApplication> IDiscordClient.GetApplicationInfoAsync(RequestOptions options) | ||||
=> await GetApplicationInfoAsync().ConfigureAwait(false); | => await GetApplicationInfoAsync().ConfigureAwait(false); | ||||
@@ -1883,7 +1885,7 @@ namespace Discord.WebSocket | |||||
async Task IDiscordClient.StopAsync() | async Task IDiscordClient.StopAsync() | ||||
=> await StopAsync().ConfigureAwait(false); | => await StopAsync().ConfigureAwait(false); | ||||
async Task<IReadOnlyCollection<IRelationship>> IDiscordClient.GetRelationshipsAsync() | |||||
async Task<IReadOnlyCollection<IRelationship>> IDiscordClient.GetRelationshipsAsync(RequestOptions options) | |||||
=> await GetRelationshipsAsync(); | => await GetRelationshipsAsync(); | ||||
} | } | ||||
} | } |
@@ -8,16 +8,18 @@ namespace Discord.WebSocket | |||||
public IUser User { get; internal set; } | 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) | 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 | |||||
}; | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -65,12 +65,6 @@ namespace Discord.WebSocket | |||||
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" : "")})"; | ||||
internal SocketUser Clone() => MemberwiseClone() as SocketUser; | internal SocketUser Clone() => MemberwiseClone() as SocketUser; | ||||
//IUser | |||||
Task<IDMChannel> IUser.GetDMChannelAsync(CacheMode mode, RequestOptions options) | |||||
=> Task.FromResult<IDMChannel>(GlobalUser.DMChannel); | |||||
async Task<IDMChannel> IUser.CreateDMChannelAsync(RequestOptions options) | |||||
=> await CreateDMChannelAsync(options).ConfigureAwait(false); | |||||
public async Task AddFriendAsync(RequestOptions options = null) | public async Task AddFriendAsync(RequestOptions options = null) | ||||
=> await Discord.ApiClient.AddFriendAsync(Id, options); | => await Discord.ApiClient.AddFriendAsync(Id, options); | ||||