private static async Task Main() { Program p = new Program(); var appBuilder = new MikiAppBuilder(); await p.LoadServicesAsync(appBuilder); MikiApp app = appBuilder.Build(); await p.LoadDiscord(app); p.LoadLocales(); for (int i = 0; i < Global.Config.MessageWorkerCount; i++) { MessageBucket.AddWorker(); } using (var c = new MikiContext()) { List <User> bannedUsers = await c.Users.Where(x => x.Banned).ToListAsync(); foreach (var u in bannedUsers) { app.GetService <EventSystem>().MessageFilter .Get <UserFilter>().Users.Add(u.Id.FromDbLong()); } } await Task.Delay(-1); }
private static async Task Main(string[] args) { Program p = new Program(); if (args.Length > 0) { if (args.Any(x => x.ToLowerInvariant() == "--migrate" && x.ToLowerInvariant() == "-m")) { await new MikiDbContextFactory().CreateDbContext(new string[] { }).Database.MigrateAsync(); return; } } var appBuilder = new MikiAppBuilder(); await p.LoadServicesAsync(appBuilder); MikiApp app = appBuilder.Build(); await p.LoadDiscord(app); p.LoadLocales(); for (int i = 0; i < Global.Config.MessageWorkerCount; i++) { MessageBucket.AddWorker(); } using (var scope = app.Services.CreateScope()) { var context = scope.ServiceProvider .GetService <MikiDbContext>(); List <IsBanned> bannedUsers = await context.IsBanned .Where(x => x.ExpirationDate > DateTime.UtcNow) .ToListAsync(); foreach (var u in bannedUsers) { app.GetService <EventSystem>().MessageFilter .Get <UserFilter>().Users.Add(u.UserId.FromDbLong()); } } await Task.Delay(-1); }