static async Task AsyncMain() { _coreLogger.Info("Starting up bot"); _coreLogger.Info("Reading Config"); var config = CoreConfig.ReadConfig(); var client = new DiscordSocketClient(); client.Log += logging; _coreLogger.Info("Initializing Service Manager"); var serviceDepMap = new ServiceDependencyMap(client); _coreLogger.Info("Initializing Command Handler"); var cmdHandler = new CommandHandler(client, serviceDepMap); await cmdHandler.AddAllCommands(); _coreLogger.Info("Beginning Login and Connection to Discord"); await client.LoginAsync(TokenType.Bot, config.Token); await client.StartAsync(); cmdHandler.StartListening(); await Task.Delay(-1); }
public static void SetDependencyMap(ServiceDependencyMap dependencyMap) { if (DepMap == null) { DepMap = dependencyMap; } }
public WelcomeDmService(ServiceDependencyMap map) { _dbContext = new WelcomeDbContext(); map.Add(_dbContext); _assetsDir = Path.Combine(Directory.GetCurrentDirectory(), "Assets"); }
public CommandHandler(DiscordSocketClient client, ServiceDependencyMap dependencyMap) { _client = client; _dependencyMap = dependencyMap; _commandService = new CommandService(new CommandServiceConfig() { DefaultRunMode = RunMode.Sync, CaseSensitiveCommands = false }); _commandService.AddTypeReader <DateTime>(new DateTypeReader()); _commandService.AddTypeReader <Segment>(new SegmentTypeReader(_dependencyMap)); _commandService.AddTypeReader <Profile>(new ProfileTypeReader(_dependencyMap)); HelpService.RegisterCommandService(_commandService); ExtendedModuleBase.SetDependencyMap(dependencyMap); _client.MessageReceived += handler; }
public SegmentTypeReader(ServiceDependencyMap depMap) { _dbContext = depMap.Get <WelcomeDbContext>(); }