public async Task <IActionResult> AutocompleteUsers(string query)
        {
            await UserGuild.DownloadUsersAsync();

            var result = UserGuild.Users
                         .Where(d => d.Username.OrdinalContains(query))
                         .Take(10)
                         .Select(d => new ModixUser {
                Name = $"{d.Username}#{d.Discriminator}", UserId = d.Id, AvatarHash = d.AvatarId
            });

            return(Ok(result));
        }
Beispiel #2
0
        public async Task <IActionResult> AutocompleteUsers(string query)
        {
            await UserGuild.DownloadUsersAsync();

            var result = UserGuild.Users is null
                ? Enumerable.Empty <ModixUser>()
                : UserGuild.Users
                         .Where(d => d.Username.OrdinalContains(query))
                         .Take(10)
                         .Select(d => ModixUser.FromSocketGuildUser(d));

            return(Ok(result));
        }