static async Task Main(string[] args) { Console.Title = $"{Name} v{Version} by {Author}"; Program.WriteCopyright(); LoggingInitializationExtensions.EnableUnhandledExceptionLogging(); Console.WriteLine("Starting {0} host. Press Ctrl+C to stop and exit.", Name);; Console.WriteLine(); IHost host = Host.CreateDefaultBuilder(args) .ConfigureAppConfiguration((context, builder) => { // add log settings builder.AddJsonFile("logsettings.json", optional: true, reloadOnChange: true); builder.AddJsonFile($"logsettings.{context.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true); }) .ConfigureSerilog() .ConfigureServices((context, services) => { services.Configure <ApplicationOptions>(context.Configuration); services.AddWatchers(); }) .Build(); await host.RunAsync().ConfigureAwait(false); }
static async Task Main(string[] args) { LoggingInitializationExtensions.EnableUnhandledExceptionLogging(); IHost host = Host.CreateDefaultBuilder(args) //.ConfigureAppConfiguration((context, builder) => //{ // context. //}) .ConfigureSecretsFiles() .ConfigureSerilog() .ConfigureServices((context, services) => { // configure options services.Configure <EinherjiOptions>(context.Configuration); services.Configure <DatabaseOptions>(context.Configuration.GetSection("Database")); services.Configure <CachingOptions>(MongoUserDataStore.CacheOptionName, context.Configuration.GetSection("Caching").GetSection(MongoUserDataStore.CacheOptionName)); services.Configure <CachingOptions>(MongoNetflixAccountStore.CacheOptionName, context.Configuration.GetSection("Caching").GetSection(MongoNetflixAccountStore.CacheOptionName)); services.Configure <CachingOptions>(MongoStellarisModsStore.CacheOptionName, context.Configuration.GetSection("Caching").GetSection(MongoStellarisModsStore.CacheOptionName)); services.Configure <CachingOptions>(MongoCommunityGoalsHistoryStore.CacheOptionName, context.Configuration.GetSection("Caching").GetSection(MongoCommunityGoalsHistoryStore.CacheOptionName)); services.Configure <CachingOptions>(MongoPatchbotGameStore.CacheOptionName, context.Configuration.GetSection("Caching").GetSection(MongoPatchbotGameStore.CacheOptionName)); services.Configure <CachingOptions>(MongoGameServerStore.CacheOptionName, context.Configuration.GetSection("Caching").GetSection(MongoGameServerStore.CacheOptionName)); services.Configure <DiscordOptions>(context.Configuration.GetSection("Discord")); services.Configure <CommandsOptions>(context.Configuration.GetSection("Discord").GetSection("Commands")); services.Configure <NetflixAccountOptions>(context.Configuration.GetSection("Netflix")); services.Configure <BotChannelsRedirectionOptions>(context.Configuration.GetSection("BotChannelsRedirection")); services.Configure <PiholeOptions>(context.Configuration.GetSection("Kathara").GetSection("Pihole")); services.Configure <PatchbotOptions>(context.Configuration.GetSection("Patchbot")); services.Configure <CommunityGoalsOptions>(context.Configuration.GetSection("EliteCommunityGoals")); services.Configure <RandomStatusOptions>(context.Configuration.GetSection("RandomStatus")); services.Configure <GameServersOptions>(context.Configuration.GetSection("GameServers")); // add framework services // add custom services services.AddDiscordClient(); services.AddCommands(); // add bot features services.AddIntel(); services.AddNetflixAccount(); services.AddStellaris(); services.AddAdministration(); services.AddBotChannelsRedirection(); services.AddPihole(); services.AddPatchbot(); services.AddEliteCommunityGoals(); services.AddGameServers(); }) .Build(); await host.RunAsync().ConfigureAwait(false); }