diff options
| author | Zeyla Hellyer <[email protected]> | 2018-07-15 23:32:50 -0700 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2018-07-15 23:33:59 -0700 |
| commit | 9da766976929417c4b8f487f8ec05b6f8b3f43ef (patch) | |
| tree | 83cfae143ad7c1c4423d5ac35bf71d6e0bc6b882 /src/framework | |
| parent | Support multiple prefixes for command-groups (#343) (diff) | |
| download | serenity-9da766976929417c4b8f487f8ec05b6f8b3f43ef.tar.xz serenity-9da766976929417c4b8f487f8ec05b6f8b3f43ef.zip | |
Fix some clippy lints
Some lints were not resolved due to causing API changes. Most lints in the
framework were left unfixed.
Diffstat (limited to 'src/framework')
| -rw-r--r-- | src/framework/standard/create_help_command.rs | 3 | ||||
| -rw-r--r-- | src/framework/standard/help_commands.rs | 40 | ||||
| -rw-r--r-- | src/framework/standard/mod.rs | 10 |
3 files changed, 25 insertions, 28 deletions
diff --git a/src/framework/standard/create_help_command.rs b/src/framework/standard/create_help_command.rs index 12a0b55..b1fd8ec 100644 --- a/src/framework/standard/create_help_command.rs +++ b/src/framework/standard/create_help_command.rs @@ -264,8 +264,7 @@ impl CreateHelpCommand { /// If `Some(String)` was set as `striked_commands_tip` and the `String` is empty, /// the creator will substitute content based on the `HelpBehaviour`-settings. pub(crate) fn finish(mut self) -> Arc<Help> { - - if &self.0.striked_commands_tip_in_dm == &Some(String::new()) { + if self.0.striked_commands_tip_in_dm == Some(String::new()) { self.0.striked_commands_tip_in_dm = self.produce_strike_text("direct messages"); } diff --git a/src/framework/standard/help_commands.rs b/src/framework/standard/help_commands.rs index a088ef1..d951222 100644 --- a/src/framework/standard/help_commands.rs +++ b/src/framework/standard/help_commands.rs @@ -48,7 +48,7 @@ use super::{ }; use utils::Colour; -fn error_embed(channel_id: &ChannelId, input: &str, colour: Colour) { +fn error_embed(channel_id: ChannelId, input: &str, colour: Colour) { let _ = channel_id.send_message(|m| { m.embed(|e| e.colour(colour).description(input)) }); @@ -123,7 +123,7 @@ pub fn is_command_visible(command_options: &Arc<CommandOptions>, msg: &Message, return help_options.wrong_channel != HelpBehaviour::Hide; } - return false + false } /// Posts an embed showing each individual command group and its commands. @@ -199,7 +199,7 @@ pub fn with_embeds<H: BuildHasher>( if let Some((command_name, command)) = found { let command = command.options(); if !command.help_available { - error_embed(&msg.channel_id, &help_options.no_help_available_text, help_options.embed_error_colour); + error_embed(msg.channel_id, &help_options.no_help_available_text, help_options.embed_error_colour); return Ok(()); } @@ -253,7 +253,7 @@ pub fn with_embeds<H: BuildHasher>( } let error_msg = help_options.command_not_found_text.replace("{}", name); - error_embed(&msg.channel_id, &error_msg, help_options.embed_error_colour); + error_embed(msg.channel_id, &error_msg, help_options.embed_error_colour); return Ok(()); } @@ -284,7 +284,7 @@ pub fn with_embeds<H: BuildHasher>( let mut desc = String::new(); if let Some(ref prefixes) = group.prefixes { - let _ = write!(desc, "{}: `{}`\n", &help_options.group_prefix, prefixes.join("`, `")); + let _ = writeln!(desc, "{}: `{}`", &help_options.group_prefix, prefixes.join("`, `")); } let mut has_commands = false; @@ -307,17 +307,17 @@ pub fn with_embeds<H: BuildHasher>( if let Some(member) = guild.members.get(&msg.author.id) { if has_correct_roles(&cmd, &guild, &member) { - let _ = write!(desc, "`{}`\n", name); + let _ = writeln!(desc, "`{}`", name); has_commands = true; } else { match help_options.lacking_role { HelpBehaviour::Strike => { let name = format!("~~`{}`~~", &name); - let _ = write!(desc, "{}\n", name); + let _ = writeln!(desc, "{}", name); has_commands = true; }, HelpBehaviour::Nothing => { - let _ = write!(desc, "`{}`\n", name); + let _ = writeln!(desc, "`{}`", name); has_commands = true; }, HelpBehaviour::Hide => { @@ -327,18 +327,18 @@ pub fn with_embeds<H: BuildHasher>( } } } else { - let _ = write!(desc, "`{}`\n", name); + let _ = writeln!(desc, "`{}`", name); has_commands = true; } } else { match help_options.lacking_permissions { HelpBehaviour::Strike => { let name = format!("~~`{}`~~", &name); - let _ = write!(desc, "{}\n", name); + let _ = writeln!(desc, "{}", name); has_commands = true; }, HelpBehaviour::Nothing => { - let _ = write!(desc, "`{}`\n", name); + let _ = writeln!(desc, "`{}`", name); has_commands = true; }, HelpBehaviour::Hide => { @@ -350,11 +350,11 @@ pub fn with_embeds<H: BuildHasher>( match help_options.wrong_channel { HelpBehaviour::Strike => { let name = format!("~~`{}`~~", &name); - let _ = write!(desc, "{}\n", name); + let _ = writeln!(desc, "{}", name); has_commands = true; }, HelpBehaviour::Nothing => { - let _ = write!(desc, "`{}`\n", name); + let _ = writeln!(desc, "`{}`", name); has_commands = true; }, HelpBehaviour::Hide => { @@ -459,23 +459,23 @@ pub fn plain<H: BuildHasher>( if !command.aliases.is_empty() { let aliases = command.aliases.join("`, `"); - let _ = write!(result, "**{}:** `{}`\n", help_options.aliases_label, aliases); + let _ = writeln!(result, "**{}:** `{}`", help_options.aliases_label, aliases); } if let Some(ref desc) = command.desc { - let _ = write!(result, "**{}:** {}\n", help_options.description_label, desc); + let _ = writeln!(result, "**{}:** {}", help_options.description_label, desc); } if let Some(ref usage) = command.usage { - let _ = write!(result, "**{}:** `{} {}`\n", help_options.usage_label, command_name, usage); + let _ = writeln!(result, "**{}:** `{} {}`", help_options.usage_label, command_name, usage); } if let Some(ref example) = command.example { - let _ = write!(result, "**{}:** `{} {}`\n", help_options.usage_sample_label, command_name, example); + let _ = writeln!(result, "**{}:** `{} {}`", help_options.usage_sample_label, command_name, example); } if group_name != "Ungrouped" { - let _ = write!(result, "**{}:** {}\n", help_options.grouped_label, group_name); + let _ = writeln!(result, "**{}:** {}", help_options.grouped_label, group_name); } let only = if command.dm_only { @@ -511,9 +511,9 @@ pub fn plain<H: BuildHasher>( }; if let Some(ref striked_command_text) = striked_command_tip { - let _ = write!(result, "{}\n{}\n\n", &help_options.individual_command_tip, striked_command_text); + let _ = writeln!(result, "{}\n{}\n", &help_options.individual_command_tip, striked_command_text); } else { - let _ = write!(result, "{}\n\n", &help_options.individual_command_tip); + let _ = writeln!(result, "{}\n", &help_options.individual_command_tip); } let mut group_names = groups.keys().collect::<Vec<_>>(); diff --git a/src/framework/standard/mod.rs b/src/framework/standard/mod.rs index 42da699..1d7158a 100644 --- a/src/framework/standard/mod.rs +++ b/src/framework/standard/mod.rs @@ -529,14 +529,12 @@ impl StandardFramework { // Is there a custom check for when this bucket applies? // If not, assert that it does always. let apply = bucket.check.as_ref().map_or(true, |check| { - let apply = feature_cache! {{ + feature_cache! {{ let guild_id = message.guild_id; (check)(context, guild_id, message.channel_id, message.author.id) } else { (check)(context, message.channel_id, message.author.id) - }}; - - apply + }} }); if apply && rate_limit > 0i64 { @@ -955,9 +953,9 @@ impl StandardFramework { /// to alter help-commands. pub fn customised_help<F>(mut self, f: HelpFunction, c: F) -> Self where F: FnOnce(CreateHelpCommand) -> CreateHelpCommand { - let a = c(CreateHelpCommand(HelpOptions::default(), f)); + let res = c(CreateHelpCommand(HelpOptions::default(), f)); - self.help = Some(a.finish()); + self.help = Some(res.finish()); self } |