Exemple #1
0
 public Administration(FloraRandom random, FloraDebugLogger logger, DiscordSocketClient client, Configuration config, BotGameHandler botGames)
 {
     _random   = random;
     _logger   = logger;
     _client   = client;
     _botGames = botGames;
     _config   = config;
 }
Exemple #2
0
        public Games(FloraRandom random, FloraDebugLogger logger, BotGameHandler botGames, WoodcuttingLocker woodcuttingLocker, Configuration config, HeartLocker heartLocker)
        {
            _random   = random;
            _logger   = logger;
            _botGames = botGames;
            _config   = config;

            _woodcuttingLocker = woodcuttingLocker;
            _healthLocker      = heartLocker;
        }
Exemple #3
0
        public async Task AsyncMain()
        {
            _config          = JsonConvert.DeserializeObject <Configuration>(File.ReadAllText(@"data/config.json"));
            _config.Shutdown = false;
            _random          = new FloraRandom();

            _reactions = new Reactions(_random);
            await _reactions.LoadReactionsFromDatabase();

            _botGames = new BotGameHandler(_random, _client, _logger);
            await _botGames.LoadBotGamesFromDB();

            //Services
            InitServices();

            var provider = _map.BuildServiceProvider();

            //Command Setup
            await InitCommands(provider);

            _commands.Log += Log;

            await _client.LoginAsync(TokenType.Bot, _config.Token);

            await _client.StartAsync();

            provider.GetRequiredService <CommandHandler>();
            //provider.GetRequiredService<StartupHandler>();
            provider.GetRequiredService <ReactionHandler>();
            provider.GetRequiredService <ImageRateLimitHandler>();
            provider.GetRequiredService <ReactionHandler>();

            _logger.Log("Updating User List", "Startup");

            foreach (SocketGuild guild in _client.Guilds)
            {
                await guild.DownloadUsersAsync();
            }

            if (_config.RotatingGames)
            {
                _logger.Log("Starting game rotation", "RotatingGames");
                WorkingTask();
            }

            //Block task until program is closed
            await Task.Delay(-1);
        }