Exemple #1
0
 public BlacklistService(IDependencyMap dependencies)
 {
     Client   = dependencies.Get <DiscordSocketClient>();
     Database = dependencies.Get <BotDbContext>();
     Client.GuildAvailable += CheckBlacklist(false);
     Client.JoinedGuild    += CheckBlacklist(true);
 }
Exemple #2
0
 public Owner(Bot bot,
              CounterSet counters,
              BotDbContext db,
              LogService logs,
              DiscordSocketClient client) : base(db)
 {
     Bot        = bot;
     Counters   = counters;
     LogService = logs;
     Client     = client;
 }
Exemple #3
0
        async Task Run()
        {
            Log.Info($"Starting...");
            using (var database = new BotDbContext()) {
                await Initialize(database);

                while (!ExitSource.Task.IsCompleted)
                {
                    try {
                        await MainLoop();
                    } catch (Exception error) {
                        Log.Error(error);
                    }
                }
            }
        }
Exemple #4
0
        async Task Initialize(BotDbContext db)
        {
            if (_initialized)
            {
                return;
            }
            StartTime = DateTime.Now;
            Log.Info("Initializing...");
            var config = new DiscordSocketConfig();

            Client = new DiscordSocketClient(config);
            var CommandService = new CommandService();
            var map            = new DependencyMap();

            map.Add(this);
            map.Add(map);
            map.Add(Client);

            map.Add(db);
            map.Add(new CounterSet(new ActivatorFactory <SimpleCounter>()));
            map.Add(new LogSet());

            map.Add(new DatabaseService(map));

            map.Add(new LogService(map, ExecutionDirectory));
            map.Add(new CounterService(map));

            map.Add(CommandService);
            await CommandService.AddModulesAsync(Assembly.GetEntryAssembly());

            map.Add(new BotCommandService(map));

            map.Add(new TempService(map));
            map.Add(new BlacklistService(map));
            map.Add(new AnnounceService(map));
            map.Add(new SearchService(map));

            _initialized = true;
        }
Exemple #5
0
 public Blacklist(BotDbContext db) : base(db)
 {
 }
Exemple #6
0
 protected DatabaseHouraiModule(BotDbContext db)
 {
     Database = db;
 }
Exemple #7
0
 public SearchService(IDependencyMap map)
 {
     Logs     = map.Get <LogSet>();
     Database = map.Get <BotDbContext>();
 }