public static IAsyncEnumerable <IReadOnlyCollection <RestGuildUser> > GetUsersAsync(IGuild guild, BaseDiscordClient client, ulong?fromUserId, int?limit, RequestOptions options) { return(new PagedAsyncEnumerable <RestGuildUser>( DiscordConfig.MaxMessagesPerBatch, async(info, ct) => { var args = new GetGuildMembersParams { Limit = info.PageSize }; if (info.Position != null) { args.AfterUserId = info.Position.Value; } var models = await client.ApiClient.GetGuildMembersAsync(guild.Id, args, options).ConfigureAwait(false); return models.Select(x => RestGuildUser.Create(client, guild, x)).ToImmutableArray(); }, nextPage: (info, lastPage) => { if (lastPage.Count != DiscordConfig.MaxMessagesPerBatch) { return false; } info.Position = lastPage.Max(x => x.Id); return true; }, start: fromUserId, count: limit )); }
public virtual async Task <IReadOnlyCollection <IGuildUser> > GetUsersAsync() { var args = new GetGuildMembersParams(); var models = await Discord.ApiClient.GetGuildMembersAsync(Id, args).ConfigureAwait(false); return(models.Select(x => new GuildUser(this, new User(x.User), x)).ToImmutableArray()); }
public async Task <IActionResult> GetGuildMembersAsync(Snowflake guildId, [FromQuery] Dictionary <string, string> queryMap) { var args = new GetGuildMembersParams(); args.LoadQueryMap(queryMap); args.Validate(); var user = new User(); if (args.After.IsSpecified) { user.Id = args.After.Value; } return(Ok(new[] { new GuildMember { User = user } })); }