コード例 #1
0
ファイル: Program.cs プロジェクト: Zod-/UDHBot
        private async Task MainAsync()
        {
            DeserializeSettings();

            _client = new DiscordSocketClient(new DiscordSocketConfig
            {
                LogLevel = LogSeverity.Verbose, AlwaysDownloadUsers = true, MessageCacheSize = 50
            });

            _commandService =
                new CommandService(new CommandServiceConfig {
                CaseSensitiveCommands = false, DefaultRunMode = RunMode.Async
            });
            _loggingService   = new LoggingService(_client, _settings);
            _databaseService  = new DatabaseService(_loggingService, _settings);
            _publisherService = new PublisherService(_client, _databaseService, _settings);
            _animeService     = new AnimeService(_client, _loggingService, _settings);
            _feedService      = new FeedService(_client, _settings);
            _updateService    = new UpdateService(_client, _loggingService, _publisherService, _databaseService, _animeService, _settings,
                                                  _feedService);
            _userService = new UserService(_databaseService, _loggingService, _updateService, _settings, _userSettings);

            _audioService      = new AudioService(_loggingService, _client, _settings);
            _casinoService     = new CasinoService(_loggingService, _updateService, _databaseService, _settings);
            _currencyService   = new CurrencyService();
            _serviceCollection = new ServiceCollection();
            _serviceCollection.AddSingleton(_loggingService);
            _serviceCollection.AddSingleton(_databaseService);
            _serviceCollection.AddSingleton(_userService);
            //_serviceCollection.AddSingleton(_work);
            //TODO: rework work service
            _serviceCollection.AddSingleton(_publisherService);
            _serviceCollection.AddSingleton(_updateService);
            _serviceCollection.AddSingleton(_audioService);
            _serviceCollection.AddSingleton(_animeService);
            _serviceCollection.AddSingleton(_casinoService);
            _serviceCollection.AddSingleton(_settings);
            _serviceCollection.AddSingleton(_rules);
            _serviceCollection.AddSingleton(_payWork);
            _serviceCollection.AddSingleton(_userSettings);
            _serviceCollection.AddSingleton(_currencyService);
            _services = _serviceCollection.BuildServiceProvider();


            await InstallCommands();

            _client.Log += Logger;

            // await InitCommands();

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

            await _client.StartAsync();

            _client.Ready += () =>
            {
                Console.WriteLine("Bot is connected");
                //_audio.Music();
                return(Task.CompletedTask);
            };

            await Task.Delay(-1);
        }
コード例 #2
0
        public UpdateService(DiscordSocketClient client, LoggingService loggingService, PublisherService publisherService,
                             DatabaseService databaseService, UserService userService, AnimeService animeService)
        {
            _client           = client;
            _loggingService   = loggingService;
            _publisherService = publisherService;
            _databaseService  = databaseService;
            _userService      = userService;
            _animeService     = animeService;
            _token            = new CancellationToken();
            _random           = new Random();

            UpdateLoop();
        }