Esempio n. 1
0
        public async Task DakkaAsync(CommandContext ctx)
        {
            var interactivity = ctx.Client.GetInteractivityModule();
            var msg           = await ctx.RespondAsync($"HOW MUCH DAKKA???");

            var reactionList = new DiscordEmoji[]
            {
                DiscordEmoji.FromName(ctx.Client, ":one:"),
                DiscordEmoji.FromName(ctx.Client, ":five:"),
                DiscordEmoji.FromName(ctx.Client, ":nine:")
            };

            var moreReactions = new DiscordEmoji[]
            {
                DiscordEmoji.FromName(ctx.Client, ":thumbsup:"),
                DiscordEmoji.FromName(ctx.Client, ":thumbsdown:"),
            };

            for (int i = 0; i < reactionList.Length; i++)
            {
                await msg.CreateReactionAsync(reactionList[i]);
            }

            var reactions = await interactivity.CollectReactionsAsync(msg, TimeSpan.FromSeconds(30));

            var biggestResult = reactions
                                .Reactions.OrderByDescending(e => e.Value)
                                .FirstOrDefault(e => reactionList.Contains(e.Key)).Key.Name.Replace(":", string.Empty);

            bool moreDakka = false;
            //do
            //{
            int resultCount;

            switch (biggestResult)
            {
            case "one": resultCount = 1; break;

            case "five": resultCount = 5; break;

            case "nine": resultCount = 9; break;

            default: resultCount = 1; break;
            }

            var dakkaBuilder = new List <string>();

            for (int i = 0; i < resultCount; i++)
            {
                dakkaBuilder.Add("DAKKA");
            }

            msg = await ctx.RespondAsync(string.Join(" ", dakkaBuilder) + "!!!!! MORE???");

            for (int i = 0; i < moreReactions.Length; i++)
            {
                await msg.CreateReactionAsync(moreReactions[i]);
            }

            reactions = await interactivity.CollectReactionsAsync(msg, new TimeSpan(1, 0, 30));

            biggestResult = reactions
                            .Reactions.OrderByDescending(e => e.Value)
                            .FirstOrDefault(e => reactionList.Contains(e.Key)).Key.Name.Replace(":", string.Empty);

            moreDakka = biggestResult == "thumbsup";
            //} while (moreDakka);
        }