Fixed GetGuildMembers for servers larger than 1000 members.
This commit is contained in:
@@ -30,7 +30,7 @@ namespace Discord.API
|
|||||||
public IRestClient RestClient { get; private set; }
|
public IRestClient RestClient { get; private set; }
|
||||||
public IRequestQueue RequestQueue { get; private set; }
|
public IRequestQueue RequestQueue { get; private set; }
|
||||||
|
|
||||||
internal DiscordRawClient(RestClientProvider restClientProvider)
|
public DiscordRawClient(RestClientProvider restClientProvider)
|
||||||
{
|
{
|
||||||
_restClient = restClientProvider(DiscordConfig.ClientAPIUrl);
|
_restClient = restClientProvider(DiscordConfig.ClientAPIUrl);
|
||||||
_restClient.SetHeader("accept", "*/*");
|
_restClient.SetHeader("accept", "*/*");
|
||||||
@@ -474,11 +474,11 @@ namespace Discord.API
|
|||||||
{
|
{
|
||||||
if (args == null) throw new ArgumentNullException(nameof(args));
|
if (args == null) throw new ArgumentNullException(nameof(args));
|
||||||
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));
|
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));
|
||||||
if (args.Limit <= 0) throw new ArgumentOutOfRangeException(nameof(args.Limit));
|
if (args.Limit.IsSpecified && args.Limit <= 0) throw new ArgumentOutOfRangeException(nameof(args.Limit));
|
||||||
if (args.Offset < 0) throw new ArgumentOutOfRangeException(nameof(args.Offset));
|
if (args.Offset.IsSpecified && args.Offset < 0) throw new ArgumentOutOfRangeException(nameof(args.Offset));
|
||||||
|
|
||||||
int limit = args.Limit.GetValueOrDefault(int.MaxValue);
|
int limit = args.Limit.GetValueOrDefault(int.MaxValue);
|
||||||
int offset = args.Offset;
|
int offset = args.Offset.GetValueOrDefault(0);
|
||||||
|
|
||||||
List<GuildMember[]> result;
|
List<GuildMember[]> result;
|
||||||
if (args.Limit.IsSpecified)
|
if (args.Limit.IsSpecified)
|
||||||
@@ -498,6 +498,7 @@ namespace Discord.API
|
|||||||
result.Add(models);
|
result.Add(models);
|
||||||
|
|
||||||
limit -= DiscordConfig.MaxUsersPerBatch;
|
limit -= DiscordConfig.MaxUsersPerBatch;
|
||||||
|
offset += models.Length;
|
||||||
|
|
||||||
//Was this an incomplete (the last) batch?
|
//Was this an incomplete (the last) batch?
|
||||||
if (models.Length != DiscordConfig.MaxUsersPerBatch) break;
|
if (models.Length != DiscordConfig.MaxUsersPerBatch) break;
|
||||||
|
|||||||
Reference in New Issue
Block a user