예제 #1
0
        public static InteractivityExtension UseInteractivity(this DiscordClient c, InteractivityConfiguration cfg)
        {
            if (c.GetExtension <InteractivityExtension>() != null)
            {
                throw new Exception("Interactivity module is already enabled for this client!");
            }

            var m = new InteractivityExtension(cfg);

            c.AddExtension(m);
            return(m);
        }
예제 #2
0
 internal InteractivityExtension(InteractivityConfiguration cfg)
 {
     this.Config = new InteractivityConfiguration(cfg);
 }
예제 #3
0
        public static async Task <IReadOnlyDictionary <int, InteractivityExtension> > UseInteractivityAsync(this DiscordShardedClient c, InteractivityConfiguration cfg)
        {
            var modules = new Dictionary <int, InteractivityExtension>();
            await c.InitializeShardsAsync().ConfigureAwait(false);

            foreach (var shard in c.ShardClients.Select(xkvp => xkvp.Value))
            {
                var m = shard.GetExtension <InteractivityExtension>();
                if (m == null)
                {
                    m = shard.UseInteractivity(cfg);
                }

                modules[shard.ShardId] = m;
            }

            return(new ReadOnlyDictionary <int, InteractivityExtension>(modules));
        }
예제 #4
0
 /// <summary>
 /// Creates a new instance of <see cref="InteractivityConfiguration"/>, copying the properties of another configuration.
 /// </summary>
 /// <param name="other">Configuration the properties of which are to be copied.</param>
 public InteractivityConfiguration(InteractivityConfiguration other)
 {
     this.PaginationBehavior = other.PaginationBehavior;
     this.PaginationTimeout  = other.PaginationTimeout;
     this.Timeout            = other.Timeout;
 }
 /// <summary>
 /// Creates a new instance of <see cref="InteractivityConfiguration"/>, copying the properties of another configuration.
 /// </summary>
 /// <param name="other">Configuration the properties of which are to be copied.</param>
 public InteractivityConfiguration(InteractivityConfiguration other)
 {
     this.Timeout = other.Timeout;
 }
예제 #6
0
        public static IReadOnlyDictionary <int, InteractivityExtension> UseInteractivity(this DiscordShardedClient c, InteractivityConfiguration cfg)
        {
            var modules = new Dictionary <int, InteractivityExtension>();

            c.InitializeShardsAsync().GetAwaiter().GetResult();

            foreach (var shard in c.ShardClients.Select(xkvp => xkvp.Value))
            {
                var m = shard.GetModule <InteractivityExtension>();
                if (m == null)
                {
                    m = shard.UseInteractivity(cfg);
                }

                modules.Add(shard.ShardId, m);
            }

            return(new ReadOnlyDictionary <int, InteractivityExtension>(modules));
        }
예제 #7
0
 internal InteractivityModule(InteractivityConfiguration cfg)
 {
     this.Config = cfg;
 }