private async Task PreCommandHandle(SocketMessage s)
        {
            //DataAccess Db = new DataAccess();
            var msg = s as SocketUserMessage;
            //if (msg == null) return;
            //var context = new SocketCommandContext(_client, msg);
            //UserAccountModel model = new UserAccountModel();
            //model = Db.GetUser(context.User.Id);
            //// Mute check
            //if ((model.IsMuted == 1 && context.User.IsBot == false) || (model.IsMuted == 1 && context.Guild.OwnerId != context.User.Id))
            //{
            //    if (msg.Content.StartsWith("!Appeal mute") || msg.Content.StartsWith("!Appeal Mute") || msg.Content.StartsWith("!appeal mute") || msg.Content.StartsWith("!appeal Mute"))
            //    {
            //        await HandleCommandAsync(msg);
            //        await Task.Delay(1);
            //        //var newMsg = msg.Content.TrimStart((char)12);
            //        //await Appeal((SocketGuildUser)context.User, newMsg, context.Guild);
            //    }
            //    await context.Message.DeleteAsync();
            //    return;
            //}
            //if (context.User.IsBot) return;

            DataAccess Db  = new DataAccess();
            var        msg = s as SocketUserMessage;

            if (msg == null)
            {
                return;
            }
            var context            = new SocketCommandContext(_client, msg);
            UserAccountModel model = new UserAccountModel();

            model = Db.GetUser(context.User.Id);
            // Mute check

            if (model.IsMuted == 1 && context.User.IsBot == false)
            {
                if (useraccount.IsMuted)
                {
                    if (msg.Content.StartsWith("!Appeal mute") || msg.Content.StartsWith("!Appeal Mute") || msg.Content.StartsWith("!appeal mute") || msg.Content.StartsWith("!appeal Mute"))
                    {
                        await HandleCommandAsync(msg);

                        await Task.Delay(1);

                        //var newMsg = msg.Content.TrimStart((char)12);
                        //await Appeal((SocketGuildUser)context.User, newMsg, context.Guild);
                    }
                    await context.Message.DeleteAsync();

                    return;
                }
            }
            if (context.User.IsBot)
            {
                return;
            }
            await HandleCommandAsync(msg);
        }
Beispiel #2
0
        public UserAccountModel GetUser(ulong userId)
        {
            string idString = userId.ToString();

            using (IDbConnection connection = new SQLiteConnection(DataBaseHandler.CnnVal(nameS)))
            {
                var t = Global.Client.GetGuild(Config.bot.guildID).GetUser(userId);
                UserAccountModel model = new UserAccountModel();
                //select * from UserAcc where @IdString
                var users  = connection.Query($"SELECT * from UserAcc where Id = " + t.Id + ";");
                var UsersL = users.ToList();
                foreach (var p in UsersL)
                {
                    //Console.WriteLine($" Id: {p.Id} \n Warnings: {p.NumberOfWarnings} \n Is Muted: {p.IsMuted}");
                    model.Id = (ulong)p.Id;
                    model.NumberOfWarnings = (byte)p.NumberOfWarnings;
                    model.IsMuted          = (byte)p.IsMuted;
                    return(model);
                }
                return(model);
            }
        }
Beispiel #3
0
        public void UpdateUserWarning(ulong userId, byte warningAdd)
        {
            var idString = Converter.ConvertToString(userId);

            using (IDbConnection connection = new SQLiteConnection(DataBaseHandler.CnnVal(nameS)))
            {
                UserAccountModel model = new UserAccountModel();
                connection.Open();

                var users  = connection.Query($"SELECT * from UserAcc where Id = " + userId + ";");
                var UsersL = users.ToList();
                foreach (var p in UsersL)
                {
                    Console.WriteLine($" Id: {p.Id} \n Warnings: {p.NumberOfWarnings} \n Is Muted: {p.IsMuted}");
                    model.Id = (ulong)p.Id;
                    model.NumberOfWarnings = (byte)p.NumberOfWarnings;
                    model.IsMuted          = (byte)p.IsMuted;
                    connection.Execute($"update UserAcc set NumberOfWarnings = {warningAdd + model.NumberOfWarnings} WHERE Id = {userId};");
                }

                connection.Close();
            }
        }