/// <summary> /// Gets a Gateway by a Token /// </summary> /// <param name="token">The token of the Gateway</param> /// <param name="shardCount"></param> /// <param name="shardingSystem">The Sharding System to use for this Gateway</param> /// <returns>IGateway</returns> public static IGateway GetGateway(string token, int?shardCount, ShardingSystem shardingSystem) { token = token.RemoveTokenPrefix(); if (Gateways.ContainsKey(token)) { return(Gateways[token]); } var instance = new Gateway(token, shardCount, shardingSystem); Gateways[token] = instance; return(instance); }
/// <summary> /// Creates a new instance of Gateway from a Token & a Shard Count. /// </summary> /// <param name="token">The token of this Gateway</param> /// <param name="shardCount">The Shard Count to use for this Gateway</param> /// <param name="shardingSystem">The Sharding System to use for this Gateway</param> public Gateway(string token, int?shardCount, ShardingSystem shardingSystem = ShardingSystem.DEFAULT) { RawToken = token; ProvidedShardCount = shardCount; ShardingSystem = shardingSystem; }
/// <summary> /// Creates a new instance and uses either provided or recommended shard count. /// </summary> /// <param name="token">The token of the bot.</param> /// <param name="shardCount">The shard count to use.</param> /// <param name="identifyOptions">Options to send while Identifying</param> /// <param name="shardingSystem">The Sharding System to use by the Gateway</param> public Cluster(string token, int?shardCount = null, IdentifyOptions identifyOptions = null, ShardingSystem shardingSystem = ShardingSystem.DEFAULT) { Gateway = Util.GetGateway(token, shardCount, shardingSystem); IdentifyOptions = identifyOptions; }
/// <summary> /// Creates a new instance which spawns a range of Shards from id. /// </summary> /// <param name="token">The token of the bot.</param> /// <param name="shardCount">The shard count to use.</param> /// <param name="shardIds">The ids of shards to spawn.</param> /// <param name="identifyOptions">Options to send while Identifying</param> /// <param name="shardingSystem">The Sharding System to use by the Gateway</param> public Cluster(string token, int shardCount, IEnumerable <int> shardIds, IdentifyOptions identifyOptions = null, ShardingSystem shardingSystem = ShardingSystem.DEFAULT) : this(token, shardCount, identifyOptions, shardingSystem) => ShardIds = shardIds;
/// <summary> /// Creates an instance of Shard. /// </summary> /// <param name="token">The Token to use.</param> /// <param name="id">The Id of this Shard.</param> /// <param name="shardCount">The shard count that is used.</param> /// <param name="identifyOptions">Options to send while Identifying</param> /// <param name="shardingSystem">The Sharding System to use by the Gateway</param> // ReSharper disable once UnusedMember.Global public Shard(string token, int id, int shardCount, IdentifyOptions identifyOptions = null, ShardingSystem shardingSystem = ShardingSystem.DEFAULT) { IdentifyOptions = identifyOptions; ShardGateway = Util.GetGateway(token, shardCount, shardingSystem); Id = id; }