public async Task Roles(string nameOrSpecies) { // If a role with this name exists, that's what we'll prioritize (users can use the genus + species overload if they need to). // If no such role exists, check for a species with this name instead. Role role = await BotUtils.GetRoleFromDb(nameOrSpecies); if (role is null) { // No such role exists, so check if a species exists with the given name instead. Species[] matching_species = await BotUtils.GetSpeciesFromDb("", nameOrSpecies); if (matching_species.Count() == 1) { // If only one species was returned, show the roles assigned to that species. await Roles(matching_species[0]); } else if (matching_species.Count() > 1) { // If multiple species were returned, provide a list of matching species for the user to choose from. await BotUtils.ReplyValidateSpeciesAsync(Context, matching_species); } if (matching_species.Count() > 0) { return; } } // If we got here, the role is eiher not null, or it is null, but no species with the given name exists. // In this case, proceed to validate the role, and display its information if possible. if (!await BotUtils.ReplyAsync_ValidateRole(Context, role)) { return; } // List all extant species with this role. List <Species> species_list = new List <Species>(await BotUtils.GetSpeciesFromDbByRole(role)); species_list.RemoveAll(x => x.IsExtinct); species_list.Sort((lhs, rhs) => lhs.ShortName.CompareTo(rhs.ShortName)); Bot.PaginatedMessageBuilder embed = new Bot.PaginatedMessageBuilder(EmbedUtils.SpeciesListToEmbedPages(species_list, fieldName: string.Format("Extant species with this role ({0}):", species_list.Count()))); embed.SetTitle(string.Format("Role: {0}", StringUtils.ToTitleCase(role.name))); embed.SetDescription(role.GetDescriptionOrDefault()); await Bot.DiscordUtils.SendMessageAsync(Context, embed.Build()); }