Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Configure(IApplicationBuilder app)
- {
- var serviceProvider = app.ApplicationServices;
- ServiceProvider = serviceProvider;
- app
- .UseCors(o => o.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin())
- .UseMvc()
- .UseWelcomePage();
- serviceProvider.GetRequiredService<LoggingService>();
- serviceProvider.GetRequiredService<MessageHandler>();
- serviceProvider.GetRequiredService<UserJoinedHandler>();
- serviceProvider.GetRequiredService<Statistics>().Init().Wait();
- serviceProvider.GetRequiredService<DiscordService>().StartAsync().Wait();
- }
- public async Task StartAsync()
- {
- var dcConfig = Config.GetSection("Discord");
- var token = dcConfig["Token"];
- var activityMessage = dcConfig["Activity"];
- if (string.IsNullOrEmpty(token))
- throw new ConfigException("Missing bot token in config.");
- await Client.LoginAsync(TokenType.Bot, token);
- await Client.StartAsync();
- await SetActivity(activityMessage);
- await Commands.AddModulesAsync(Assembly.GetEntryAssembly(), Services);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement