diff options
| author | Austin Hellyer <[email protected]> | 2016-12-26 20:24:04 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2016-12-26 20:24:04 -0800 |
| commit | ada07fae09f3521f44d81613f26839d69c1fc7ef (patch) | |
| tree | 7328dc3d037e5e038d9959430f26d520cbe34065 /src/client | |
| parent | Use $crate in the command macro (diff) | |
| download | serenity-ada07fae09f3521f44d81613f26839d69c1fc7ef.tar.xz serenity-ada07fae09f3521f44d81613f26839d69c1fc7ef.zip | |
Accept u64 shard counts
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/gateway/prep.rs | 2 | ||||
| -rw-r--r-- | src/client/gateway/shard.rs | 6 | ||||
| -rw-r--r-- | src/client/mod.rs | 13 |
3 files changed, 12 insertions, 9 deletions
diff --git a/src/client/gateway/prep.rs b/src/client/gateway/prep.rs index 844a558..40ce9a6 100644 --- a/src/client/gateway/prep.rs +++ b/src/client/gateway/prep.rs @@ -53,7 +53,7 @@ pub fn parse_ready(event: GatewayEvent, } } -pub fn identify(token: &str, shard_info: Option<[u8; 2]>) -> Value { +pub fn identify(token: &str, shard_info: Option<[u64; 2]>) -> Value { ObjectBuilder::new() .insert("op", OpCode::Identify.num()) .insert_object("d", |mut object| { diff --git a/src/client/gateway/shard.rs b/src/client/gateway/shard.rs index bc2b813..6b70dd5 100644 --- a/src/client/gateway/shard.rs +++ b/src/client/gateway/shard.rs @@ -64,7 +64,7 @@ pub struct Shard { last_sequence: u64, login_type: LoginType, session_id: Option<String>, - shard_info: Option<[u8; 2]>, + shard_info: Option<[u64; 2]>, token: String, ws_url: String, /// The voice connections that this Shard is responsible for. The Shard will @@ -99,7 +99,7 @@ impl Shard { /// ``` pub fn new(base_url: &str, token: &str, - shard_info: Option<[u8; 2]>, + shard_info: Option<[u64; 2]>, login_type: LoginType) -> Result<(Shard, ReadyEvent, Receiver<WebSocketStream>)> { let url = prep::build_gateway_url(base_url)?; @@ -172,7 +172,7 @@ impl Shard { /// /// For example, if using 3 shards in total, and if this is shard 1, then it /// can be read as "the second of three shards". - pub fn shard_info(&self) -> Option<[u8; 2]> { + pub fn shard_info(&self) -> Option<[u64; 2]> { self.shard_info } diff --git a/src/client/mod.rs b/src/client/mod.rs index 94d2c54..075f323 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -281,7 +281,10 @@ impl Client { pub fn start_autosharded(&mut self) -> Result<()> { let res = rest::get_bot_gateway()?; - self.start_connection(Some([0, res.shards as u8 - 1, res.shards as u8])) + let x = res.shards as u64 - 1; + let y = res.shards as u64; + + self.start_connection(Some([0, x, y])) } /// Establish a sharded connection and start listening for events. @@ -297,7 +300,7 @@ impl Client { /// on effectively using sharding. /// /// [gateway docs]: gateway/index.html#sharding - pub fn start_shard(&mut self, shard: u8, shards: u8) -> Result<()> { + pub fn start_shard(&mut self, shard: u64, shards: u64) -> Result<()> { self.start_connection(Some([shard, shard, shards])) } @@ -316,7 +319,7 @@ impl Client { /// [`start_shard`]: #method.start_shard /// [`start_shard_range`]: #method.start_shards /// [Gateway docs]: gateway/index.html#sharding - pub fn start_shards(&mut self, total_shards: u8) -> Result<()> { + pub fn start_shards(&mut self, total_shards: u64) -> Result<()> { self.start_connection(Some([0, total_shards - 1, total_shards])) } @@ -350,7 +353,7 @@ impl Client { /// [`start_shard`]: #method.start_shard /// [`start_shards`]: #method.start_shards /// [Gateway docs]: gateway/index.html#sharding - pub fn start_shard_range(&mut self, range: [u8; 2], total_shards: u8) + pub fn start_shard_range(&mut self, range: [u64; 2], total_shards: u64) -> Result<()> { self.start_connection(Some([range[0], range[1], total_shards])) } @@ -783,7 +786,7 @@ impl Client { // 2: total number of shards the bot is sharding for // // Not all shards need to be initialized in this process. - fn start_connection(&mut self, shard_data: Option<[u8; 3]>) -> Result<()> { + fn start_connection(&mut self, shard_data: Option<[u64; 3]>) -> Result<()> { // Update the framework's current user if the feature is enabled. // // This also acts as a form of check to ensure the token is correct. |