public DiscordBotHandler(string [] args) { BotSettings = new BotSettings(); Configuration = new ConfigurationBuilder() .SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), "Settings")) .AddJsonFile("shared.json") .AddJsonFile("bot.json") .AddJsonFile("uploader.json") .AddCommandLine(args) .Build(); Configuration.Bind(BotSettings); if (BotSettings.UseRemoteDatabase) { /* * DB = new OctoKitGameDatabase( HttpClient , Configuration ["GitUsername"] , Configuration ["GitPassword"] ) * { * InitialLoad = true , * }; */ DB = new HttpGameDatabase(HttpClient) { InitialLoad = true, }; } else { DB = new FileSystemGameDatabase(); } Configuration.Bind(DB.SharedSettings); DiscordInstance = new DiscordClient(new DiscordConfiguration() { AutoReconnect = true, TokenType = TokenType.Bot, Token = BotSettings.DiscordToken, #if DEBUG MinimumLogLevel = Microsoft.Extensions.Logging.LogLevel.Debug, #endif }); //TODO:not sure if this has to be any other way, but singleton for now will work Services = new ServiceCollection() .AddSingleton(DB) .AddSingleton(Configuration); CommandsModule = DiscordInstance.UseCommandsNext(new CommandsNextConfiguration() { Services = Services.BuildServiceProvider(), }); InteractivityModule = DiscordInstance.UseInteractivity(new InteractivityConfiguration()); CommandsModule.RegisterCommands <MatchTrackerCommands>(); }
private static async Task DeleteAllJsonFiles(FileSystemGameDatabase fileSystemGameDatabase) { var mainpath = fileSystemGameDatabase.SharedSettings.BaseRecordingFolder; var filestodelete = Directory.EnumerateFiles(mainpath, "*.json", new EnumerationOptions() { RecurseSubdirectories = true, ReturnSpecialDirectories = false }).ToList(); filestodelete.ForEach(x => File.Delete(x)); }