diff options
| author | acdenisSK <[email protected]> | 2017-07-27 06:42:48 +0200 |
|---|---|---|
| committer | acdenisSK <[email protected]> | 2017-07-27 07:30:23 +0200 |
| commit | 550030264952f0e0043b63f4582bb817ef8bbf37 (patch) | |
| tree | b921e2f78fd603a5ca671623083a32806fd16090 /src/framework/help_commands.rs | |
| parent | Use a consistent indentation style (diff) | |
| download | serenity-550030264952f0e0043b63f4582bb817ef8bbf37.tar.xz serenity-550030264952f0e0043b63f4582bb817ef8bbf37.zip | |
rustfmt
Diffstat (limited to 'src/framework/help_commands.rs')
| -rw-r--r-- | src/framework/help_commands.rs | 72 |
1 files changed, 35 insertions, 37 deletions
diff --git a/src/framework/help_commands.rs b/src/framework/help_commands.rs index d589ded..7f863b4 100644 --- a/src/framework/help_commands.rs +++ b/src/framework/help_commands.rs @@ -28,16 +28,13 @@ use std::sync::Arc; use std::fmt::Write; use super::command::InternalCommand; use super::{Command, CommandGroup, CommandOrAlias}; -use ::client::Context; -use ::model::{ChannelId, Message}; -use ::utils::Colour; +use client::Context; +use model::{ChannelId, Message}; +use utils::Colour; fn error_embed(channel_id: &ChannelId, input: &str) { - let _ = channel_id - .send_message(|m| m - .embed(|e| e - .colour(Colour::dark_red()) - .description(input))); + let _ = + channel_id.send_message(|m| m.embed(|e| e.colour(Colour::dark_red()).description(input))); } fn remove_aliases(cmds: &HashMap<String, CommandOrAlias>) -> HashMap<&String, &InternalCommand> { @@ -74,7 +71,8 @@ fn remove_aliases(cmds: &HashMap<String, CommandOrAlias>) -> HashMap<&String, &I pub fn with_embeds(_: &mut Context, msg: &Message, groups: HashMap<String, Arc<CommandGroup>>, - args: &[String]) -> Result<(), String> { + args: &[String]) + -> Result<(), String> { if !args.is_empty() { let name = args.join(" "); @@ -97,7 +95,7 @@ pub fn with_embeds(_: &mut Context, error_embed(&msg.channel_id, &format!("Did you mean \"{}\"?", name)); return Ok(()); - } + }, } } } @@ -111,28 +109,27 @@ pub fn with_embeds(_: &mut Context, let _ = msg.channel_id.send_message(|m| { m.embed(|e| { - let mut embed = e.colour(Colour::rosewater()) - .title(command_name); + let mut embed = e.colour(Colour::rosewater()).title(command_name); if let Some(ref desc) = command.desc { embed = embed.description(desc); } if let Some(ref usage) = command.usage { - embed = embed.field(|f| f - .name("Usage") - .value(&format!("`{} {}`", command_name, usage))); + embed = embed.field(|f| { + f.name("Usage") + .value(&format!("`{} {}`", command_name, usage)) + }); } if let Some(ref example) = command.example { - embed = embed.field(|f| f - .name("Sample usage") - .value(&format!("`{} {}`", command_name, example))); + embed = embed.field(|f| { + f.name("Sample usage") + .value(&format!("`{} {}`", command_name, example)) + }); } if group_name != "Ungrouped" { - embed = embed.field(|f| f - .name("Group") - .value(&group_name)); + embed = embed.field(|f| f.name("Group").value(&group_name)); } let available = if command.dm_only { @@ -143,9 +140,7 @@ pub fn with_embeds(_: &mut Context, "In DM and guilds" }; - embed = embed.field(|f| f - .name("Available") - .value(available)); + embed = embed.field(|f| f.name("Available").value(available)); embed }) @@ -161,8 +156,8 @@ pub fn with_embeds(_: &mut Context, return Ok(()); } - let _ = msg.channel_id.send_message(|m| m - .embed(|mut e| { + let _ = msg.channel_id.send_message(|m| { + m.embed(|mut e| { e = e.colour(Colour::rosewater()) .description("To get help with an individual command, pass its \ name as an argument to this command."); @@ -200,7 +195,8 @@ pub fn with_embeds(_: &mut Context, } e - })); + }) + }); Ok(()) } @@ -227,7 +223,8 @@ pub fn with_embeds(_: &mut Context, pub fn plain(_: &mut Context, msg: &Message, groups: HashMap<String, Arc<CommandGroup>>, - args: &[String]) -> Result<(), String> { + args: &[String]) + -> Result<(), String> { if !args.is_empty() { let name = args.join(" "); @@ -241,7 +238,7 @@ pub fn plain(_: &mut Context, command_name.to_owned() }; - if name == with_prefix || name == *command_name { + if name == with_prefix || name == *command_name { match *command { CommandOrAlias::Command(ref cmd) => { found = Some((command_name, cmd)); @@ -249,7 +246,7 @@ pub fn plain(_: &mut Context, CommandOrAlias::Alias(ref name) => { let _ = msg.channel_id.say(&format!("Did you mean {:?}?", name)); return Ok(()); - } + }, } } } @@ -280,12 +277,12 @@ pub fn plain(_: &mut Context, result.push_str("**Available:** "); result.push_str(if command.dm_only { - "Only in DM" - } else if command.guild_only { - "Only in guilds" - } else { - "In DM and guilds" - }); + "Only in DM" + } else if command.guild_only { + "Only in guilds" + } else { + "In DM and guilds" + }); result.push_str("\n"); let _ = msg.channel_id.say(&result); @@ -294,7 +291,8 @@ pub fn plain(_: &mut Context, } } - let _ = msg.channel_id.say(&format!("**Error**: Command `{}` not found.", name)); + let _ = msg.channel_id + .say(&format!("**Error**: Command `{}` not found.", name)); return Ok(()); } |