Exemplo n.º 1
0
        private async Task Client_Ready()
        {
            AddonLoader.Load(Client);
            Assembly[]  assemblies     = AppDomain.CurrentDomain.GetAssemblies();
            List <Type> commandClasses = new List <Type>();

            foreach (Assembly assembly in assemblies)
            {
                commandClasses.AddRange(assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(ModuleBase)) && !t.IsAbstract).ToList());
            }

            checkNewUserEntries();
            StatusNotifierService.InitializeService(Me);
            MusicCommands.Initialize(Client);
            RoleManagerService.InitializeHandler(Client, BotConfiguration);
            ApiRequestService.Initialize(BotConfiguration);
            UserManagerService.InitializeHandler(Client);
            await CommandHandlerService.InitializeHandler(Client, BotConfiguration, commandClasses, prefixDictionary, !CredentialManager.OptionalSettings.Contains("CleverApi"));

            CacheService.InitializeHandler();
            VoiceRewardService.InitializeHandler(Client, BotConfiguration, !CredentialManager.OptionalSettings.Contains("CleverApi"));
            switch (startValue)
            {
            case 0:
                //shutdown
                break;

            case 1:
                //restarting
                await Me.SendMessageAsync("I have restored and restarted successfully.");

                break;

            case 2:
                //updating
                //check if an update is nessasarry
                await Me.SendMessageAsync("I at all the new features and restarted successfully.");

                break;

            default:
                break;
            }
            if (!CredentialManager.OptionalSettings.Contains("WeatherApiKey"))
            {
                if (!CredentialManager.OptionalSettings.Contains("WeatherPlace"))
                {
                    MoodDictionary.InitializeMoodDictionary(Client, BotConfiguration);
                    await MoodHandlerService.InitializeHandler(Client, BotConfiguration);
                }
                WeatherSubscriptionService.InitializeWeatherSub(Client, BotConfiguration);
            }
        }
Exemplo n.º 2
0
        private async Task Client_Ready()
        {
            IServiceProvider services = new ServiceCollection()
                                        .AddSingleton(Client)
                                        .AddSingleton <CleverbotApiHandler>()
                                        .AddSingleton <ColornamesApiHandler>()
                                        .AddSingleton <KonachanApiHandler>()
                                        .AddSingleton <WeatherApiHandler>()
                                        .AddSingleton <WikipediaApiHandler>()
                                        .AddSingleton(CredentialManager)
                                        .BuildServiceProvider();

            AddonLoader.Load(Client);
            Assembly[]  assemblies     = AppDomain.CurrentDomain.GetAssemblies();
            List <Type> commandClasses = new List <Type>();

            foreach (Assembly assembly in assemblies)
            {
                commandClasses.AddRange(assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(ModuleBase)) && !t.IsAbstract).ToList());
            }
            VoiceRewardService.InitializeHandler(Client, BotConfiguration, !CredentialManager.OptionalSettings.Contains("CleverApi"));
            checkNewUserEntries();
            StatusNotifierService.InitializeService(Me);
            MusicCommands.Initialize(Client);
            RoleManagerService.InitializeHandler(Client, BotConfiguration);
            UserManagerService.InitializeHandler(Client, fileLogger);
            await CommandHandlerService.InitializeHandler(Client, BotConfiguration, commandClasses, prefixDictionary, !CredentialManager.OptionalSettings.Contains("CleverApi"), fileLogger, services);

            CacheService.InitializeHandler();
            switch (startValue)
            {
            case 0:
                //shutdown
                break;

            case 1:
                //restarting
                await Me.SendMessageAsync("I have restored and restarted successfully.");

                break;

            case 2:
                //updating
                //check if an update is nessasarry
                await Me.SendMessageAsync("I at all the new features and restarted successfully.");

                break;

            default:
                break;
            }
            if (!CredentialManager.OptionalSettings.Contains("WeatherApiKey"))
            {
                if (!CredentialManager.OptionalSettings.Contains("WeatherPlace"))
                {
                    MoodDictionary.InitializeMoodDictionary(Client, BotConfiguration);
                    await MoodHandlerService.InitializeHandler(Client, BotConfiguration, services.GetRequiredService <WeatherApiHandler>(), fileLogger);
                }
                WeatherSubscriptionService.InitializeWeatherSub(Client, BotConfiguration, services.GetRequiredService <WeatherApiHandler>());
            }
            consoleLogger.Info($"Addons loaded: {AddonLoader.LoadedAddonsCount}");
            consoleLogger.Info($"User loaded: {DatabaseAccess.Instance.Users.Count}");
            consoleLogger.Info($"Registered guilds: {Client.Guilds.Count}");
            consoleLogger.Info($"Bot start up time: {(DateTime.Now - startTime).TotalSeconds} s");
        }