Esempio n. 1
0
        public async Task Answer(IMessageChannel puzzle, [Remainder] string content)
        {
            var user    = (IGuildUser)Context.User;
            var message = Context.Message;
            await message.DeleteAsync();

            var code   = puzzle.Id.ToString();
            var userId = user.Id.ToString();
            var answer = content.Replace("|", "");

            if (_data.HasUserCompletedPuzzle(userId, code))
            {
                await ReplyAsync(_quotes.GetAlreadySolvedMessage(user.Mention));

                return;
            }

            var answers      = _data.GetPuzzleData(code, PuzzleDataType.Answer);
            var closeAnswers = _data.GetPuzzleData(code, PuzzleDataType.CloseAnswer);

            if (answers.Count == 0)
            {
                await ReplyAsync(_quotes.GetNotAPuzzleMessage(user.Mention));

                return;
            }

            string log_msg = $"User **{user.Username}** (`{user.Id}`) - Puzzle <#{puzzle.Id}> - ||{answer}|| ";

            if (Contains(answers, answer))
            {
                await ReplyAsync(_quotes.GetCorrectAnswerMessage(user.Mention));

                await _actions.ProcessCorrectAnswer(user, code);

                await _actions.UpdateLeaderboard();

                log_msg += ":white_check_mark:";
            }
            else if (Contains(closeAnswers, answer))
            {
                await ReplyAsync(_quotes.GetCloseAnswerMessage(user.Mention));

                log_msg += ":radio_button:";
            }
            else
            {
                await ReplyAsync(_quotes.GetWrongAnswerMessage(user.Mention));

                log_msg += ":x:";
            }

            await _actions.SendMessageToChannelAsync(log_msg, Constants.LOGS_CHANNEL);
        }
Esempio n. 2
0
        private async Task OnUserJoined(SocketGuildUser u)
        {
            if (u.IsBot)
            {
                return;
            }

            if (_data.GetUserById(u.Id.ToString()) == null)
            {
                var user = new UserModel(u.Id.ToString(), u.Username);
                _data.AddOrUpdateUser(user);
            }

            await _actions.SendMessageToChannelAsync(_quotes.GetGreetingMessage(u.Mention),
                                                     Constants.GREETING_CHANNEL);

            await _actions.SendHelpMessageAsync(u);
        }