コード例 #1
0
ファイル: Settings.cs プロジェクト: Damitrix/Sabrina
        private async Task <bool> Introduction(DiscordDmChannel dm, CommandContext ctx)
        {
            bool userAgrees = false;

            while (!userAgrees)
            {
                await dm.TriggerTypingAsync();

                await Task.Delay(8000);

                await dm.SendMessageAsync($"I'm gonna send you a bunch of Questions.{Environment.NewLine}" +
                                          $"Please answer them.{Environment.NewLine}" +
                                          $"Don't worry, this is not a Quiz. I'll give you enough time.{Environment.NewLine}" +
                                          $"Most questions will also have possible answers written below. Some may require you, to input a text, some may only require a number.{Environment.NewLine}" +
                                          $"For every Question, there will be a \"Default\" option. If you don't know what to take / don't have a preference, take this.");

                await dm.TriggerTypingAsync();

                await Task.Delay(12000);

                var builder = new DiscordEmbedBuilder()
                {
                    Title = "Do you understand what i just wrote?",
                    Url   = "http://IJustWantThisToBeBlue.com"
                };

                builder.AddField("I understand. Please go on.", "Yes");
                builder.AddField("What?", "No");

                await dm.SendMessageAsync(embed : builder.Build());

                var m = await ctx.Client.GetInteractivity().WaitForMessageAsync(
                    x => x.Channel.Id == dm.Id && x.Author.Id == ctx.Member.Id &&
                    Regex.IsMatch(x.Content, ConfirmRegex),
                    TimeSpan.FromSeconds(240));

                if (m.TimedOut)
                {
                    await dm.SendMessageAsync($"Or just don't respond at all. That's ok too :(");

                    return(false);
                }

                if (Regex.IsMatch(m.Result.Content, YesRegex))
                {
                    userAgrees = true;
                }
                else
                {
                    await dm.SendMessageAsync($"Ok, let me explain it to you.{Environment.NewLine}" +
                                              $"I've just sent you a Question. Directly underneath it, you can see a fat \"**I understand**\", and a smaller \"Yes\". Right?{Environment.NewLine}" +
                                              $"The \"**I understand**\", is basically just a Description of your possible answer. In this case, the Answer is \"Yes\".{Environment.NewLine}" +
                                              $"So you can either answer exactly with \"Yes\", or exactly with \"No\".{Environment.NewLine}" +
                                              $"So let's try this again.");

                    await dm.TriggerTypingAsync();

                    await Task.Delay(10000);
                }
            }

            return(userAgrees);
        }