Beispiel #1
0
        private static async void StrawpollGetPoll()
        {
            StrawpollService service = StrawpollService.Instance;
            StrawpollPoll    poll    = await service.GetPoll(1);

            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(string.Format("\t{0,-15}{1}", poll.votes[i] + " votes", poll.options[i]));
                }
            }
            else
            {
                Console.WriteLine("There was an unexpected error. Please try again later");
            }
        }
        public async Task ViewAsync([Remainder][Summary("Poll ID")] string pollID)
        {
            try
            {
                if (int.TryParse(pollID, out int id))
                {
                    Debug.WriteLine($"Strawpoll View {id}");
                    StrawpollService service = StrawpollService.Instance;
                    StrawpollPoll    poll    = await service.GetPoll(id);

                    Debug.WriteLine("Get Complete");

                    await Context.Channel.SendMessageAsync(PrintStrawPoll(poll));
                }
            }
            catch (Exception)
            {
                if (Debugger.IsAttached)
                {
                    Debugger.Break();
                }
            }
        }