private async void ProcessSuggestions() { //Words that are going to be added to the database. var addedWords = new List <Suggestion>(); //While there are suggestions while (_suggestions.Count != 0) { var suggestion = _suggestions.First(); var language = Client.Languages.First(l => l.ShortName == suggestion.Language); //Word doesn't end with a letter. if (!char.IsLetter(suggestion.Word.Last())) { //Decline the suggestion. await suggestion.Message.ModifyAsync(m => m.Embed = EmbedHelper.BuildError(Locale, Locale.WrongEndLetter)); _suggestions.Remove(_suggestions.First(s => s.Author == suggestion.Author)); continue; } //Word already exists in the database. if (language.Words.Contains(suggestion.Word.ToLower())) { //Decline the suggestion. await suggestion.Message.ModifyAsync(m => m.Embed = EmbedHelper.BuildError(Locale, Locale.WordAlreadyExists)); _suggestions.Remove(_suggestions.First(s => s.Author == suggestion.Author)); continue; } //Check if the word is gibberish. var results = language.Words.Where(w => w.ToLower().StartsWith(char.ToLower(suggestion.Word.First()))) .ToList().Select(w => StringComparison.LevenshteinDistance(suggestion.Word, w)).ToList(); //This is going to be really close-checking, since //this system is automated and 0 people are checking it. if (!results.Any() || results.Max() < 0.3f) { //Word looks like gibberish, decline it. await suggestion.Message.ModifyAsync(m => m.Embed = EmbedHelper.BuildError(Locale, Locale.NotAWord)); _suggestions.Remove(_suggestions.First(s => s.Author == suggestion.Author)); continue; } //Accept the word. Yay :D addedWords.Add(suggestion); await suggestion.Message.ModifyAsync(m => m.Embed = EmbedHelper.BuildSuccess(Locale, string.Format(Locale.DoneProcessing, Client.Client.GetUser(suggestion.Author).Mention))); _suggestions.Remove(_suggestions.First(s => s.Author == suggestion.Author)); } //Update the database. UpdateDatabase(addedWords); }