Exemplo n.º 1
0
        private async Task HandleCommandAsync(SocketMessage s)
        {
            SocketUserMessage msg = s as SocketUserMessage;

            if (msg == null || msg.Author.IsBot)
            {
                return;
            }

            var context = new SocketCommandContext(_client, msg);

            await RankHandler.TryToGiveUserXP(context, msg.Author);

            int argPos = 0;

            if (msg.HasStringPrefix("!", ref argPos))
            {
                await _service.ExecuteAsync(context, argPos, null, MultiMatchHandling.Exception);
            }

            string m = msg.Content.ToLower();

            // Answer minigames
            if (context.Channel.Id == 518846214603669537)
            {
                // Answer Trivia
                if (m == "a" || m == "b" || m == "c" || m == "d")
                {
                    await MinigameHandler.Trivia.AnswerTrivia((SocketGuildUser)msg.Author, context, m);
                }

                // Answer "Who Said It?"
                int x = 0;
                if (int.TryParse(m, out x))
                {
                    if (x <= 4 && x >= 1 && MinigameHandler.WSI.isGameGoing)
                    {
                        await MinigameHandler.WSI.TryToGuess(context, x);
                    }
                }
            }

            // Print a lennyface
            if (m.Contains("lennyface"))
            {
                await context.Channel.SendMessageAsync("( ͡° ͜ʖ ͡°)");
            }

            // Fix some spelling mistakes
            for (int i = 0; i < spellingMistakes.Length; i++)
            {
                if (m.Contains(spellingMistakes[i]))
                {
                    await msg.Channel.SendMessageAsync(spellingFix[i] + "*");
                }
            }

            // Print a DM message to console
            if (s.Channel.Name.StartsWith("@"))
            {
                Console.WriteLine($" ----------\n DIRECT MESSAGE\n From: {s.Channel}\n {s}\n ----------");
            }
        }