Ejemplo n.º 1
0
        public CacheClient(
            MessageClient messenger,
            ICachePool cacheClient,
            DiscordApiClient discordClient)
        {
            _messenger     = messenger;
            _cacheClient   = cacheClient;
            _discordClient = discordClient;

            _messenger.ChannelCreate += OnChannelCreate;
            _messenger.ChannelDelete += OnChannelDelete;
            _messenger.ChannelUpdate += OnChannelUpdate;

            _messenger.GuildBanAdd    += OnGuildBanAdd;
            _messenger.GuildBanRemove += OnGuildBanRemove;

            _messenger.GuildCreate += OnGuildCreate;
            _messenger.GuildDelete += OnGuildDelete;
            _messenger.GuildUpdate += OnGuildUpdate;

            _messenger.UserUpdate += OnUserUpdate;

            _messenger.GuildRoleCreate += OnGuildRoleCreate;
            _messenger.GuildRoleDelete += OnGuildRoleDelete;
            _messenger.GuildRoleUpdate += OnGuildRoleUpdate;

            _messenger.GuildMemberAdd    += OnGuildMemberAdd;
            _messenger.GuildMemberRemove += OnGuildMemberRemove;
            _messenger.GuildMemberUpdate += OnGuildMemberUpdate;
        }
Ejemplo n.º 2
0
        public DiscordApiClient(string token, ICachePool cachePool)
        {
            RestClient = new RestClient(discordUrl + baseUrl)
                         .SetAuthorization("Bot", token);
            cache = cachePool;

            serializer = new JsonSerializerSettings()
            {
                NullValueHandling = NullValueHandling.Ignore,
            };
        }
Ejemplo n.º 3
0
 public RequestRepository(IDatabaseContext databaseContext, ICachePool cachePool)
 {
     if (databaseContext == null)
     {
         throw new ArgumentNullException("databaseContext");
     }
     _databaseContext = databaseContext;
     if (cachePool == null)
     {
         throw new ArgumentNullException("cachePool");
     }
     _cachePool = cachePool;
 }
Ejemplo n.º 4
0
        // TODO: rework params
        public Bot(int amountShards, ICachePool client, ClientInformation cInfo, string rabbitUrl)
        {
            Information = cInfo;
            CachePool   = client;

            Client = new DiscordClient(new DiscordClientConfigurations
            {
                Pool = client,
                RabbitMQExchangeName = "consumer",
                RabbitMQQueueName    = "gateway",
                RabbitMQUri          = rabbitUrl,
                Token = cInfo.Token
            });

            CacheClient = new CacheClient(
                Client._websocketClient,
                client, Client._apiClient
                );

            if (Instance == null)
            {
                Instance = this;
            }
        }
Ejemplo n.º 5
0
 public static IServiceCollection AddCacheClient(this IServiceCollection collection, ICachePool pool)
 {
     return(collection.AddSingleton(pool)
            .AddScoped((provider) => provider.GetService <ICachePool>().GetAsync().Result));
 }