public async Task SendPicture(params String[] tags) { string[] lowerTags = tags.Select(s => s.ToLowerInvariant()).ToArray(); string tagUrl = String.Empty; Rating rating; //generalize rating input, so misstyping isnt so bad string lowerRating = tags[0].ToLower(); string ratingElement = lowerRating.First().ToString().ToUpper() + lowerRating.Substring(1); //try to parse as enum //check if first tag is equal to a rating if (Enum.TryParse <Rating>(ratingElement, out rating)) { //get rest of the tags string[] tagCollection = lowerTags.Skip(1).ToArray(); foreach (string tag in tagCollection) { tagUrl = tagUrl + $"{tag} "; } string response = await ApiRequestService.Request2KonachanApiAsync(tagCollection, rating); await generateImageEmbed(response, tagUrl); } else { //first arg isn't an enum foreach (string tag in lowerTags) { tagUrl = tagUrl + $"{tag} "; } string response = await ApiRequestService.Request2KonachanApiAsync(lowerTags); await generateImageEmbed(response, tagUrl); } }
public async Task SendPicture() { //search for image without tags and rating string response = await ApiRequestService.Request2KonachanApiAsync(); await generateImageEmbed(response); }