示例#1
0
文件: Core.cs 项目: abosh814/Crab
        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();
        }
示例#2
0
文件: Core.cs 项目: abosh814/Crab
 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());
 }
示例#3
0
 public static IConfigurationSection getRepoSection(string prefix)
 => ConfigUtils.getConfig().GetSection("repos").GetChildren().Where(t => (t.GetValue <string>("prefix") == prefix)).First();