Example #1
0
        private async Task MainAsync()
        {
            ServiceCollection = new ServiceCollection();
            ServiceCollection.AddSingleton <IProgram>(this);
            ServiceCollection.AddSingleton <ILoggerService, LoggerService>();

            ServiceCollection.AddSingleton <ISQLiteService, SQLiteService>();

            ServiceCollection.AddSingleton <IDiscordAppService, DiscordAppService>();
            //ServiceCollection.AddSingleton<IPollHandlerService, PollHandlerService>();
            //ServiceCollection.AddSingleton<IWebService, WebService>();

            ServiceProvider = ServiceCollection.BuildServiceProvider();

            CommandService = new CommandService(new CommandServiceConfig {
                CaseSensitiveCommands = false
            });
            CommandService.AddTypeReader <IEmote>(new EmoteTypeReader());
            await CommandService.AddModulesAsync(Assembly.GetEntryAssembly(), ServiceProvider);

            LoggerService = ServiceProvider.GetRequiredService <ILoggerService>();
            await LoggerService.LogMessageAsync("==================================================");

            await LoggerService.LogMessageAsync("The Dialga Team Discord Bot (.NET Core)");

            await LoggerService.LogMessageAsync("==================================================");

            await LoggerService.LogMessageAsync("Please wait while the bot is initializing...\n");

            SQLiteService = ServiceProvider.GetRequiredService <ISQLiteService>();
            await SQLiteService.InitializeDatabaseAsync();

            DiscordAppService = ServiceProvider.GetRequiredService <IDiscordAppService>();

            //PollHandlerService = ServiceProvider.GetRequiredService<IPollHandlerService>();
            //PollHandlerService.UpdatePollTask();

            //WebService = ServiceProvider.GetRequiredService<IWebService>();
            //await WebService.StartAsync();

            await LoggerService.LogMessageAsync("\nDone initializing!");

            await DiscordAppService.StartDiscordAppsAsync();
        }
Example #2
0
 public BaseModule(IDiscordAppService discordAppService, ISQLiteService sqliteService)
 {
     DiscordAppService = discordAppService;
     SQLiteService     = sqliteService;
 }
 public FreeGameNotificationModule(ISQLiteService sqliteService, IDiscordAppService discordAppService)
 {
     SQLiteService     = sqliteService;
     DiscordAppService = discordAppService;
 }
Example #4
0
 public PollHandlerService(ISQLiteService sqliteService, IDiscordAppService discordAppService)
 {
     SQLiteService = sqliteService;
     DiscordAppService = discordAppService;
 }