Beispiel #1
0
        private Task AddUserToDb(SocketMessage arg)
        {
            using (var dctx = new CwsContext())
            {
                User DbUser = dctx.Users.SingleOrDefault(x => x.UserId == arg.Author.Id);

                if (DbUser is null)
                {
                    User NewDbUser = new User
                    {
                        UserId       = arg.Author.Id,
                        Karma        = 0,
                        WarningCount = 0,
                        MessageCount = 1,
                        Tokens       = 0,
                        KarmaTime    = DateTimeOffset.Now.AddDays(-1),
                        Username     = arg.Author.Username
                    };

                    dctx.Add(NewDbUser);
                    dctx.SaveChanges();
                    return(Task.CompletedTask);
                }

                DbUser.MessageCount++;
                dctx.SaveChanges();
                return(Task.CompletedTask);
            }
        }
Beispiel #2
0
 public TagsModule(CwsContext dbContext)
 {
     _dbContext = dbContext;
 }
Beispiel #3
0
 public ModTagModule(CwsContext dbContext)
 => this._dbContext = dbContext;
Beispiel #4
0
 public CasinoModule(CwsContext dctx)
 {
     _dctx = dctx;
 }
Beispiel #5
0
 public PublicModule(CommandService service, CwsContext dctx, IConfiguration config)
 {
     _service = service;
     _dctx    = dctx;
     _config  = config;
 }
Beispiel #6
0
 public KarmaModule(CwsContext dbContext)
 {
     this._dbContext = dbContext;
 }