Пример #1
0
 public NsfwModule(HttpClient httpClient, Random random, NSFWService nsfwService, KSoft kSoft, E621 e621)
 {
     _httpClient  = httpClient;
     _random      = random;
     _nsfwService = nsfwService;
     _kSoft       = kSoft;
     _e621        = e621;
 }
Пример #2
0
        public async Task InitializeAsync()
        {
            _ = PublicVariables.Colors;
            _configuration = ConfigurationService.LoadNewConfig();
            _database      = new DatabaseService(_configuration);
            _httpClient    = new HttpClient();
            _kSoft         = new KSoft(_configuration.KsoftApiKey);
            _e621          = new E621(_configuration.E621UserAgent);
            _client        = new DiscordShardedClient(new DiscordSocketConfig
            {
                AlwaysDownloadUsers = true,
                DefaultRetryMode    = RetryMode.AlwaysRetry,
                LogLevel            = LogSeverity.Verbose,
                MessageCacheSize    = 2048,
                TotalShards         = _configuration.ShardCount
            });
            _commands = new CommandService(new CommandServiceConfig
            {
                CaseSensitiveCommands = false,
                LogLevel       = LogSeverity.Info,
                DefaultRunMode = RunMode.Sync
            });
            _lavalinkManager = new LavalinkManager(_client, new LavalinkManagerConfig
            {
                RESTHost      = _configuration.RESTHost,
                RESTPort      = _configuration.RESTPort,
                WebSocketHost = _configuration.WebSocketHost,
                WebSocketPort = _configuration.WebSocketPort,
                Authorization = _configuration.Authorization,
                TotalShards   = _configuration.ShardCount,
            });
            _interactive = new InteractiveService(_client);
            _services    = new ServiceCollection()
                           .AddSingleton(_client)
                           .AddSingleton(_commands)
                           .AddSingleton(_configuration)
                           .AddSingleton(_database)
                           .AddSingleton(_interactive)
                           .AddSingleton(_httpClient)
                           .AddSingleton(_lavalinkManager)
                           .AddSingleton(_kSoft)
                           .AddSingleton(_e621)
                           .AddSingleton(new Giphy(_configuration.GiphyApiKey))
                           .AddSingleton <StatisticsService>()
                           .AddSingleton <Random>()
                           .AddSingleton <LogService>()
                           .AddSingleton <CachingService>()
                           .AddSingleton <ServerService>()
                           .AddSingleton <NSFWService>()
                           .AddSingleton <SharplinkService>()
                           .BuildServiceProvider();
            _services.GetService <LogService>();
            _services.GetService <StatisticsService>();
            _client.MessageReceived += MessageReceived;
            _client.ReactionAdded   += ReactionAdded;
            _client.Log             += Log;
            _commands.Log           += Log;
            _client.ShardReady      += Ready;

            await _commands.AddModulesAsync(Assembly.GetEntryAssembly(), _services);

            Console.WriteLine($"{_commands.Commands.Count()} commands | {_commands.Modules.Count()} modules");

            await _client.LoginAsync(TokenType.Bot, _configuration.BotToken);

            await _client.StartAsync();

            await Task.Delay(-1);
        }
Пример #3
0
 public GetE621(E621 e621)
 {
     _e621 = e621;
 }