Exemple #1
0
        private async Task InitializeAsync()
        {
            this._serviceCollection.AddSingleton(this._client);
            this._serviceCollection.AddSingleton(this._commandService);
            this._serviceCollection.AddSingleton(RemindService.GetInstance(this._client));

            this._serviceProvider = this._serviceCollection.BuildServiceProvider(true);

            await this._commandService.AddModulesAsync(Assembly.GetEntryAssembly());

            this._commandService.AddTypeReader <TimeUnitTypeReader>(new TimeUnitTypeReader());
            this._commandService.AddTypeReader <LeagueRoleTypeReader>(new LeagueRoleTypeReader());

            DiscordEventHandler eventHandler = new DiscordEventHandler(this._serviceProvider);

            this._client.Log             += Logger.Log;
            this._commandService.Log     += Logger.Log;
            this._client.Ready           += eventHandler.HandleReady;
            this._client.MessageReceived += eventHandler.HandleMessageReceived;

            using (GeneralContext database = new GeneralContext())
            {
                await database.Database.EnsureCreatedAsync();
            }
        }
Exemple #2
0
        private async Task InitializeTimers(bool allShardsLoggedIn)
        {
            if (!allShardsLoggedIn)
            {
                return;
            }

            // We need to load the cache on program start.
            await MemoryCache.Initialize();

            await ConsoleLogger.LogAsync("Memory Cache timer initialized", LogLvl.INFO);

            await KaguyaStatsFactory.Initialize();

            await ConsoleLogger.LogAsync("Kaguya stats updater initialized", LogLvl.INFO);

            await AntiRaidService.Initialize();

            await ConsoleLogger.LogAsync("Antiraid service initialized", LogLvl.INFO);

            await AutoUnmuteHandler.Initialize();

            await ConsoleLogger.LogAsync("Unmute handler initialized", LogLvl.INFO);

#if !DEBUG
            await OwnerGiveawayMessageUpdaterService.Initialize();

            await ConsoleLogger.LogAsync("Owner giveaway message updater initialized", LogLvl.INFO);

            await KaguyaPremiumRoleHandler.Initialize();

            await ConsoleLogger.LogAsync("Kaguya Premium role handler initialized", LogLvl.INFO);

            await KaguyaPremiumExpirationHandler.Initialize();

            await ConsoleLogger.LogAsync("Kaguya Premium expiration handler initialized", LogLvl.INFO);

            await RateLimitService.Initialize();

            await ConsoleLogger.LogAsync("Ratelimit service initialized", LogLvl.INFO);

            await StatsUpdater.Initialize();

            await ConsoleLogger.LogAsync("Top.gg stats updater initialized", LogLvl.INFO);

            await RemindService.Initialize();

            await ConsoleLogger.LogAsync("Remind service initialized", LogLvl.INFO);

            await UpvoteExpirationNotifier.Initialize();

            await ConsoleLogger.LogAsync("Upvote expiration notification timer initialized", LogLvl.INFO);

            await GameRotationService.Initialize();

            await ConsoleLogger.LogAsync("Game rotation timer initialized", LogLvl.INFO);
#endif
            await ConsoleLogger.LogAsync("All timers initialized.", LogLvl.INFO);
        }
Exemple #3
0
        private async Task ProcessReady()
        {
            try
            {
                DiscordSocketClient client        = this._serviceProvider.GetService(typeof(DiscordSocketClient)) as DiscordSocketClient;
                RemindService       remindService = this._serviceProvider.GetService(typeof(RemindService)) as RemindService;
                string game = string.IsNullOrWhiteSpace(Property.GameActive.Value) ? null : Property.GameActive.Value;

                await client.SetGameAsync(game);

                await remindService.StartAsync();
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }
Exemple #4
0
 public ReminderModule(RemindService remindService, InteractiveService interactiveService)
 => this._remindService = remindService;