From f3cabac6c6e555767620913b11e59da0661d32c9 Mon Sep 17 00:00:00 2001 From: Paulo Date: Sun, 24 May 2020 14:43:58 -0300 Subject: [PATCH] Do not download unless needed --- src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs index 1032b34d7..cdba2b67d 100644 --- a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs +++ b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs @@ -834,7 +834,11 @@ namespace Discord.WebSocket /// users found within this guild. /// public IAsyncEnumerable> GetUsersAsync(RequestOptions options = null) - => GuildHelper.GetUsersAsync(this, Discord, null, null, options); + { + if (HasAllMembers) + return ImmutableArray.Create(Users).ToAsyncEnumerable>(); + return GuildHelper.GetUsersAsync(this, Discord, null, null, options); + } /// public async Task DownloadUsersAsync() @@ -1202,7 +1206,7 @@ namespace Discord.WebSocket /// async Task> IGuild.GetUsersAsync(CacheMode mode, RequestOptions options) { - if (mode == CacheMode.AllowDownload) + if (mode == CacheMode.AllowDownload && !HasAllMembers) return (await GetUsersAsync(options).FlattenAsync().ConfigureAwait(false)).ToImmutableArray(); else return Users;