Esempio n. 1
0
        private async Task OnMessageReceivedAsync(SocketMessage s)
        {
            var msg = s as SocketUserMessage;

            if (msg == null)
            {
                return;
            }
            if (msg.Author.Id == _discord.CurrentUser.Id)
            {
                return;
            }

            var context = new SocketCommandContext(_discord, msg);

            int argPos = 0;

            if (msg.HasStringPrefix(_config.Prefix, ref argPos))
            {
                var result = await _commands.ExecuteAsync(context, argPos, _provider);

                if (!result.IsSuccess && !(result.Error.ToString() == "UnknownCommand"))
                {
                    await context.Channel.SendErrorAsync(result.ToString());
                }

                return;
            }

            //Code for table game
            Regex regex = new Regex(@"(?i)t\s*a\s*b\s*l\s*e");

            if (context.Guild.Id == 199658366421827584 && regex.IsMatch(context.Message.Content) && watchYourWord)
            {
                await WarnNicole(context);
            }

            if (context.Channel is IPrivateChannel && !_config.Owners.Contains(context.User.Id))
            {
                await DMHandling(context);

                return;
            }

            string reaction = _reactions.GetReactionOrNull(context.Message.Content.ToLower());

            if (reaction != null)
            {
                await context.Channel.SendMessageAsync(reaction);

                return;
            }

            if (context.Channel.Id == 199701249673658368 && context.Message.MentionedRoles.Contains(context.Guild.EveryoneRole))
            {
                ISocketMessageChannel chn = (ISocketMessageChannel)context.Guild.GetChannel(199658366421827584);
                await chn.SendMessageAsync(":weebAngry:");

                await context.Message.AddReactionAsync(context.Guild.Emotes.FirstOrDefault(x => x.Name.ToLower() == "weebangry"));
            }
            else if (context.Guild.Id == 199658366421827584 && context.Channel.Id != 199658366421827584)
            {
                int rng = _random.Next(0, 10001);
                if (rng > 9985)
                {
                    await context.Message.AddReactionAsync(context.Guild.Emotes.RandomItem());
                }
            }
        }