private static async void StrawpollPostPoll() { StrawpollService service = StrawpollService.Instance; var pollSettings = StrawpollSettings.GeneratePostSettings("Will this work?", false, new List <string> { "Yes", "No", "Maybe", "Aethex is a dick" }); StrawpollPoll poll = await service.PostPoll(pollSettings); if (poll != null) { Console.WriteLine($"ID: {poll.id}"); Console.WriteLine($"Title: {poll.title}"); Console.WriteLine($"Multi: {poll.multi}"); Console.WriteLine($"Dupcheck: {poll.dupcheck}"); Console.WriteLine($"Captcha: {poll.captcha}"); for (int i = 0; i < poll.options.Count; i++) { Console.WriteLine($"{poll.options[i]}\t\t{poll.votes[i]}"); } } else { Console.WriteLine("There was an unexpected error. Please try again later"); } }
public async Task CreateAsync([Remainder][Summary("Poll String")] string pollString) { try { var title = pollString.Substring(0, pollString.IndexOf('{')); var questionString = Regex.Match(pollString, @"\{([^)]*)\}").Groups[1].Value; Debug.WriteLine(pollString); Debug.WriteLine(title); Debug.WriteLine(questionString); StrawpollService service = StrawpollService.Instance; var pollSettings = new StrawpollSettings(); pollSettings.Title = title; pollSettings.Options.AddRange(questionString.Split(';')); foreach (var s in pollSettings.Options) { Debug.WriteLine(s); } StrawpollPoll poll = await service.PostPoll(pollSettings); Debug.WriteLine("Post Complete"); await Context.Channel.SendMessageAsync(PrintStrawPoll(poll)); } catch (Exception) { if (Debugger.IsAttached) { Debugger.Break(); } } }