Browse Source

What are these changes doing here

pull/745/head
ObsidianMinor 8 years ago
parent
commit
4bf1f82ef3
7 changed files with 20 additions and 27 deletions
  1. +1
    -5
      src/Discord.Net.Core/Entities/Users/IUser.cs
  2. +2
    -0
      src/Discord.Net.Core/IDiscordClient.cs
  3. +2
    -2
      src/Discord.Net.Rest/BaseDiscordClient.cs
  4. +3
    -6
      src/Discord.Net.Rpc/Entities/Users/RpcUser.cs
  5. +5
    -3
      src/Discord.Net.WebSocket/DiscordSocketClient.cs
  6. +7
    -5
      src/Discord.Net.WebSocket/Entities/Users/SocketRelationship.cs
  7. +0
    -6
      src/Discord.Net.WebSocket/Entities/Users/SocketUser.cs

+ 1
- 5
src/Discord.Net.Core/Entities/Users/IUser.cs View File

@@ -18,11 +18,6 @@ namespace Discord
bool IsWebhook { get; }
/// <summary> Gets the username for this user. </summary>
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>
Task AddFriendAsync(RequestOptions options = null);
@@ -30,6 +25,7 @@ namespace Discord
Task BlockUserAsync(RequestOptions options = null);
/// <summary> Removes the relationship of this user </summary>
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);
}
}

+ 2
- 0
src/Discord.Net.Core/IDiscordClient.cs View File

@@ -26,6 +26,8 @@ namespace Discord
Task<IGuild> GetGuildAsync(ulong id, 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<IReadOnlyCollection<IRelationship>> GetRelationshipsAsync(RequestOptions options = null);
Task<IInvite> GetInviteAsync(string inviteId, RequestOptions options = null);



+ 2
- 2
src/Discord.Net.Rest/BaseDiscordClient.cs View File

@@ -127,10 +127,10 @@ namespace Discord.Rest
ConnectionState IDiscordClient.ConnectionState => ConnectionState.Disconnected;
ISelfUser IDiscordClient.CurrentUser => CurrentUser;
Task<IReadOnlyCollection<IRelationship>> IDiscordClient.GetRelationshipsAsync()
Task<IReadOnlyCollection<IRelationship>> IDiscordClient.GetRelationshipsAsync(RequestOptions options)
=> 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.FromResult<IChannel>(null);


+ 3
- 6
src/Discord.Net.Rpc/Entities/Users/RpcUser.cs View File

@@ -58,17 +58,14 @@ namespace Discord.Rpc
public override string ToString() => $"{Username}#{Discriminator}";
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)
=> throw new NotSupportedException();
Task IUser.BlockUserAsync(RequestOptions options)
=> throw new NotSupportedException();
Task IUser.RemoveRelationshipAsync(RequestOptions options)
=> throw new NotSupportedException();

async Task<IDMChannel> IUser.GetOrCreateDMChannelAsync(RequestOptions options)
=> await GetOrCreateDMChannelAsync(options);
}
}

+ 5
- 3
src/Discord.Net.WebSocket/DiscordSocketClient.cs View File

@@ -257,8 +257,8 @@ namespace Discord.WebSocket
=> ClientHelper.GetConnectionsAsync(this, new RequestOptions());

/// <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()
=> Task.FromResult(State.Relationships);
@@ -1842,6 +1842,8 @@ namespace Discord.WebSocket
return State.RemoveRelationship(id);
}

internal int GetAudioId() => _nextAudioId++;

//IDiscordClient
async Task<IApplication> 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<IReadOnlyCollection<IRelationship>> IDiscordClient.GetRelationshipsAsync()
async Task<IReadOnlyCollection<IRelationship>> IDiscordClient.GetRelationshipsAsync(RequestOptions options)
=> await GetRelationshipsAsync();
}
}

+ 7
- 5
src/Discord.Net.WebSocket/Entities/Users/SocketRelationship.cs View File

@@ -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
};
}
}
}

+ 0
- 6
src/Discord.Net.WebSocket/Entities/Users/SocketUser.cs View File

@@ -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<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)
=> await Discord.ApiClient.AddFriendAsync(Id, options);


Loading…
Cancel
Save