Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 public static void SetDependencyMap(ServiceDependencyMap dependencyMap)
 {
     if (DepMap == null)
     {
         DepMap = dependencyMap;
     }
 }
Ejemplo n.º 3
0
        public WelcomeDmService(ServiceDependencyMap map)
        {
            _dbContext = new WelcomeDbContext();
            map.Add(_dbContext);

            _assetsDir = Path.Combine(Directory.GetCurrentDirectory(), "Assets");
        }
Ejemplo n.º 4
0
        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;
        }
Ejemplo n.º 5
0
 public SegmentTypeReader(ServiceDependencyMap depMap)
 {
     _dbContext = depMap.Get <WelcomeDbContext>();
 }