public async Task <Result> ListUnconfirmedUsersAsync ( [DiscordTypeHint(TypeHint.Role)] AutoroleConfiguration autorole ) { var getUsers = await _autoroles.GetUnconfirmedUsersAsync(autorole); if (!getUsers.IsSuccess) { return(Result.FromError(getUsers)); } var users = getUsers.Entity.ToList(); var getDiscordUsers = await Task.WhenAll ( users.Select(u => _guildAPI.GetGuildMemberAsync(_context.GuildID.Value, u.DiscordID)) ); var discordUsers = getDiscordUsers .Where(r => r.IsSuccess) .Select(r => r.Entity) .Where(u => u.User.HasValue) .ToList(); var pages = PaginatedEmbedFactory.SimpleFieldsFromCollection ( discordUsers, u => !u.Nickname.HasValue ? $"{u.User.Value.Username}#{u.User.Value.Discriminator} | {u.User.Value.ID}" : $"{u.Nickname} ({u.User.Value.Username}#{u.User.Value.Discriminator} | {u.User.Value.ID})", _ => "Not confirmed", "There are no users that haven't been confirmed for that role." ); return((Result)await _feedback.SendContextualPaginatedMessageAsync ( _context.User.ID, pages, ct : this.CancellationToken )); }
public async Task <RuntimeResult> ListUnconfirmedUsersAsync(AutoroleConfiguration autorole) { var getUsers = await _autoroles.GetUnconfirmedUsersAsync(autorole); if (!getUsers.IsSuccess) { return(getUsers.ToRuntimeResult()); } var users = getUsers.Entity.ToList(); var discordUsers = await Task.WhenAll ( users.Select(u => this.Context.Guild.GetUserAsync((ulong)u.DiscordID)) ); // Filter out users that are no longer in the guild discordUsers = discordUsers.Where(u => !(u is null)).ToArray(); var listMessage = PaginatedEmbedFactory.SimpleFieldsFromCollection ( _feedback, _interactivity, this.Context.User, discordUsers, u => u.Nickname is null ? $"({u.Username}#{u.Discriminator} | {u.Id})" : $"{u.Nickname} ({u.Username}#{u.Discriminator} | {u.Id})", u => "Not confirmed", "There are no users that haven't been confirmed for that role." ); await _interactivity.SendInteractiveMessageAndDeleteAsync ( this.Context.Channel, listMessage, TimeSpan.FromMinutes(5) ); return(RuntimeCommandResult.FromSuccess()); }