public async override Task startAsync() { activeCore = this; Program.client = new DiscordSocketClient(); IConfiguration _config = ConfigUtils.getConfig(); _services = ConfigureServices(); _services.GetRequiredService <LogService>(); await _services.GetRequiredService <CommandHandler>().loadAllModulesAsync(); await Program.client.LoginAsync(TokenType.Bot, _config["token"]); await Program.client.StartAsync(); }
private IServiceProvider ConfigureServices() { return(new ServiceCollection() // Base .AddSingleton(Program.client) .AddSingleton <CommandService>() .AddSingleton <CommandHandler>() // Logging .AddLogging() .AddSingleton <LogService>() // Extra .AddSingleton(ConfigUtils.getConfig()) // Add additional services here... .BuildServiceProvider()); }
public static IConfigurationSection getRepoSection(string prefix) => ConfigUtils.getConfig().GetSection("repos").GetChildren().Where(t => (t.GetValue <string>("prefix") == prefix)).First();