diff options
| author | acdenisSK <[email protected]> | 2017-07-27 08:10:41 +0200 |
|---|---|---|
| committer | acdenisSK <[email protected]> | 2017-07-27 08:10:41 +0200 |
| commit | 70b5097aaac85f970c32ceb988dbb5f5d575ee0f (patch) | |
| tree | d2f391d3b552cfae58b74748a2a2aa5ae80c7986 /src/client | |
| parent | rustfmt (diff) | |
| download | serenity-70b5097aaac85f970c32ceb988dbb5f5d575ee0f.tar.xz serenity-70b5097aaac85f970c32ceb988dbb5f5d575ee0f.zip | |
Change the config a bit, and a few nitpicks
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/dispatch.rs | 10 | ||||
| -rw-r--r-- | src/client/mod.rs | 50 |
2 files changed, 35 insertions, 25 deletions
diff --git a/src/client/dispatch.rs b/src/client/dispatch.rs index fa6193e..aec821a 100644 --- a/src/client/dispatch.rs +++ b/src/client/dispatch.rs @@ -80,10 +80,12 @@ pub fn dispatch<H: EventHandler + 'static>(event: Event, match event { Event::MessageCreate(event) => { let context = context(conn, data); - dispatch_message(context.clone(), - event.message.clone(), - event_handler, - tokio_handle); + dispatch_message( + context.clone(), + event.message.clone(), + event_handler, + tokio_handle, + ); if let Some(ref mut framework) = *framework.lock().unwrap() { helper! {{ diff --git a/src/client/mod.rs b/src/client/mod.rs index 7549d19..996b943 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -337,10 +337,10 @@ impl<H: EventHandler + 'static> Client<H> { /// use std::env; /// /// let mut client = Client::new(&env::var("DISCORD_TOKEN")?, Handler); - /// client.with_framework(MyFramework { commands: { - /// let mut map = HashMap::new(); - /// map.insert("ping".to_string(), Box::new(|msg, _| msg.channel_id.say("pong!"))); - /// map + /// client.with_framework(MyFramework { commands: { + /// let mut map = HashMap::new(); + /// map.insert("ping".to_string(), Box::new(|msg, _| msg.channel_id.say("pong!"))); + /// map /// }}); /// # Ok(()) /// # } @@ -593,8 +593,10 @@ impl<H: EventHandler + 'static> Client<H> { /// [`start_shard_range`]: #method.start_shard_range /// [Gateway docs]: gateway/index.html#sharding pub fn start_shards(&mut self, total_shards: u64) -> Result<()> { - self.start_connection([0, total_shards - 1, total_shards], - http::get_gateway()?.url) + self.start_connection( + [0, total_shards - 1, total_shards], + http::get_gateway()?.url, + ) } /// Establish a range of sharded connections and start listening for events. @@ -709,11 +711,13 @@ impl<H: EventHandler + 'static> Client<H> { for shard_number in shards_index..shards_total { let shard_info = [shard_number, shard_data[2]]; - let boot = boot_shard(&BootInfo { - gateway_url: gateway_url.clone(), - shard_info: shard_info, - token: self.token.clone(), - }); + let boot_info = BootInfo { + gateway_url: gateway_url.clone(), + shard_info: shard_info, + token: self.token.clone(), + }; + + let boot = boot_shard(&boot_info); match boot { Ok(shard) => { @@ -814,9 +818,11 @@ fn boot_shard(info: &BootInfo) -> Result<Shard> { } } - let attempt = Shard::new(info.gateway_url.clone(), - info.token.clone(), - info.shard_info); + let attempt = Shard::new( + info.gateway_url.clone(), + info.token.clone(), + info.shard_info, + ); match attempt { Ok(shard) => { @@ -842,10 +848,10 @@ fn monitor_shard<H: EventHandler + 'static>(mut info: MonitorInfo<H>) { for _ in 0..3 { let boot = boot_shard(&BootInfo { - gateway_url: info.gateway_url.clone(), - shard_info: info.shard_info, - token: info.token.clone(), - }); + gateway_url: info.gateway_url.clone(), + shard_info: info.shard_info, + token: info.token.clone(), + }); match boot { Ok(new_shard) => { @@ -877,9 +883,11 @@ fn monitor_shard<H: EventHandler + 'static>(mut info: MonitorInfo<H>) { let mut shard = info.shard.lock(); if let Err(e) = shard.shutdown_clean() { - error!("Error shutting down shard {:?}: {:?}", - shard.shard_info(), - e); + error!( + "Error shutting down shard {:?}: {:?}", + shard.shard_info(), + e + ); } } } |