Browse Source

Do not download unless needed

pull/1549/head
Paulo 5 years ago
parent
commit
f3cabac6c6
1 changed files with 6 additions and 2 deletions
  1. +6
    -2
      src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs

+ 6
- 2
src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs View File

@@ -834,7 +834,11 @@ namespace Discord.WebSocket
/// users found within this guild. /// users found within this guild.
/// </returns> /// </returns>
public IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> GetUsersAsync(RequestOptions options = null) public IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> GetUsersAsync(RequestOptions options = null)
=> GuildHelper.GetUsersAsync(this, Discord, null, null, options);
{
if (HasAllMembers)
return ImmutableArray.Create(Users).ToAsyncEnumerable<IReadOnlyCollection<IGuildUser>>();
return GuildHelper.GetUsersAsync(this, Discord, null, null, options);
}


/// <inheritdoc /> /// <inheritdoc />
public async Task DownloadUsersAsync() public async Task DownloadUsersAsync()
@@ -1202,7 +1206,7 @@ namespace Discord.WebSocket
/// <inheritdoc /> /// <inheritdoc />
async Task<IReadOnlyCollection<IGuildUser>> IGuild.GetUsersAsync(CacheMode mode, RequestOptions options) async Task<IReadOnlyCollection<IGuildUser>> IGuild.GetUsersAsync(CacheMode mode, RequestOptions options)
{ {
if (mode == CacheMode.AllowDownload)
if (mode == CacheMode.AllowDownload && !HasAllMembers)
return (await GetUsersAsync(options).FlattenAsync().ConfigureAwait(false)).ToImmutableArray(); return (await GetUsersAsync(options).FlattenAsync().ConfigureAwait(false)).ToImmutableArray();
else else
return Users; return Users;


Loading…
Cancel
Save