Exemplo n.º 1
0
        public Task StrawpollCreate([Remainder] string input)
        {
            string[] messages = input.Split('|');

            CreatedPoll newPoll = null;

            try {
                newPoll = Create.CreatePoll(messages[0], messages.Skip(1).ToList(), false, StrawPollNET.Enums.DupCheck.Normal, false);
            } catch { }

            if (newPoll == null || string.IsNullOrEmpty(newPoll.PollUrl))
            {
                return(BetterReplyAsync("Failed to create the strawpoll. Example: `!strawpoll Poll Title | Option 1 | Option 2 | Option 3`", parameters: input));
            }
            else
            {
                return(BetterReplyAsync($"{Context.User.Mention} <{newPoll.PollUrl}>", parameters: input));
            }
        }
Exemplo n.º 2
0
            public async Task SPCreateAsync()
            {
                SocketMessage title = await ResponseAsync(Context.Channel, "**Enter Title**"); //Verify empty check fail or not

                SocketMessage options = await ResponseAsync(Context.Channel, "**Enter Options (Seperated by a comma)**");

                string[] optsArray = options.Content.Split(',');

                if (optsArray.Length < 2)
                {
                    await ReplyAsync("**At least 2 options are required. Aborting!**");
                }
                bool          mult;
                SocketMessage multi = await ResponseAsync(Context.Channel, "**Multiple Entries? y or n**");

                switch (multi.Content.ToLower())
                {
                case "y":
                case "yes":
                    mult = true;
                    break;

                case "n":
                case "no":
                    mult = false;
                    break;

                default:
                    await ReplyAsync("**You did not enter yes or no. Aborting!**");

                    return;
                }
                EmbedBuilder eb = new EmbedBuilder()
                {
                    Color       = new Color(114, 137, 218),
                    Description = " "
                };

                eb.AddField(x =>
                {
                    x.Name     = "Title";
                    x.Value    = title.Content;
                    x.IsInline = false;
                });
                string        optsStr  = "";
                List <string> optsList = new List <string>();

                foreach (string opt in optsArray)
                {
                    optsStr += $"{opt}\n";
                    optsList.Add(opt);
                }
                eb.AddField(x =>
                {
                    x.Name     = "Options";
                    x.Value    = optsStr;
                    x.IsInline = false;
                });
                eb.AddField(x =>
                {
                    x.Name     = "Multiple Entries";
                    x.Value    = mult;
                    x.IsInline = false;
                });
                await ReplyAsync("**Verify StrawPoll**", embed : eb.Build());

                SocketMessage confirm = await ResponseAsync(Context.Channel, "**Is this correct? y or n**");

                bool confir;

                switch (confirm.Content.ToLower())
                {
                case "y":
                case "yes":
                    confir = true;
                    break;

                case "n":
                case "no":
                    confir = false;
                    break;

                default:
                    await ReplyAsync("**You did not enter yes or no. Aborting!**");

                    return;
                }
                if (confir)
                {
                    currentPoll = await CreatePoll(title.Content, optsList, mult, StrawPollNET.Enums.DupCheck.Normal, false);

                    pastPolls.Insert(0, currentPoll);
                    if (pastPolls.Count == 6)
                    {
                        pastPolls.RemoveAt(5);
                    }
                    await ReplyAsync($"**{title} - {currentPoll.PollUrl}**");
                }
                else
                {
                    await ReplyAsync("**Please try again.**");

                    return;
                }
            }