Esempio n. 1
0
        public static async Task <IServiceProvider> InitializeAsync(ApplicationArguments args)
        {
            IServiceProvider services = ConfigureServices(loggingBuilder =>
            {
                _ = loggingBuilder.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
                _ = loggingBuilder.AddNLog(SetupNLogConfig());
            });

            DiscordSocketClient client = services.GetService <DiscordSocketClient>();
            string token = (await DiscordClientConfiguration.LoadAsync().ConfigureAwait(false)).Token;
            await client.LoginAsync(TokenType.Bot, token).ConfigureAwait(false);

            await client.StartAsync().ConfigureAwait(false);

            CommandManager manager = services.GetService <CommandManager>();
            await manager.StartAsync().ConfigureAwait(false);

            MonkeyDBContext dbContext = services.GetRequiredService <MonkeyDBContext>();
            await DBInitializer.InitializeAsync(dbContext).ConfigureAwait(false);

            IAnnouncementService announcements = services.GetService <IAnnouncementService>();
            await announcements.InitializeAsync().ConfigureAwait(false);

            SteamGameServerService steamGameServerService = services.GetService <SteamGameServerService>();

            steamGameServerService.Initialize();

            MineCraftGameServerService minecraftGameServerService = services.GetService <MineCraftGameServerService>();

            minecraftGameServerService.Initialize();

            IGameSubscriptionService gameSubscriptionService = services.GetService <IGameSubscriptionService>();

            gameSubscriptionService.Initialize();

            IRoleButtonService roleButtonsService = services.GetService <IRoleButtonService>();

            roleButtonsService.Initialize();

            IFeedService feedService = services.GetService <IFeedService>();

            feedService.Start();

            IBattlefieldNewsService battlefieldNewsService = services.GetService <IBattlefieldNewsService>();

            battlefieldNewsService.Start();

            if (args != null && args.BuildDocumentation)
            {
                await manager.BuildDocumentationAsync().ConfigureAwait(false); // Write the documentation

                await Console.Out.WriteLineAsync("Documentation built").ConfigureAwait(false);
            }

            return(services);
        }
Esempio n. 2
0
        private static async Task StartServicesAsync(IServiceProvider services)
        {
            MonkeyDBContext dbContext = services.GetRequiredService <MonkeyDBContext>();
            await DBInitializer.InitializeAsync(dbContext);

            IReminderService reminders = services.GetService <IReminderService>();
            await reminders.InitializeAsync();

            SteamGameServerService steamGameServerService = services.GetService <SteamGameServerService>();

            steamGameServerService.Initialize();

            MineCraftGameServerService minecraftGameServerService = services.GetService <MineCraftGameServerService>();

            minecraftGameServerService.Initialize();

            IRoleDropdownService roleButtonsService = services.GetService <IRoleDropdownService>();
            await roleButtonsService.InitializeAsync();

            IFeedService feedService = services.GetService <IFeedService>();

            feedService.Start();

            IBattlefieldNewsService battlefieldNewsService = services.GetService <IBattlefieldNewsService>();

            battlefieldNewsService.Start();

            IGiveAwaysService giveAwaysService = services.GetService <IGiveAwaysService>();

            giveAwaysService.Start();

            IPollService pollService = services.GetService <IPollService>();
            await pollService.InitializeAsync();

            return;
        }
 public MineCraftGameServerModule(MineCraftGameServerService gameServerService, ILogger <MineCraftGameServerModule> logger) : base(gameServerService, logger)
 {
 }