aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLakelezz <[email protected]>2018-05-27 21:08:37 +0200
committerAlex M. M <[email protected]>2018-05-27 21:08:37 +0200
commit32c3bed1afa65d14a93d4e3d4e9e8471cfd77ced (patch)
tree54df7ddf0257f9f357af24c06e6ede8294b40c06 /src
parentCheck if cloning `unrecognised_command` is acceptable (#320) (diff)
downloadserenity-32c3bed1afa65d14a93d4e3d4e9e8471cfd77ced.tar.xz
serenity-32c3bed1afa65d14a93d4e3d4e9e8471cfd77ced.zip
do not show the strikethrough-tip If no HelpBehaviour is `Strike` (#321)
Diffstat (limited to 'src')
-rw-r--r--src/framework/standard/create_help_command.rs20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/framework/standard/create_help_command.rs b/src/framework/standard/create_help_command.rs
index 8899a41..12a0b55 100644
--- a/src/framework/standard/create_help_command.rs
+++ b/src/framework/standard/create_help_command.rs
@@ -218,17 +218,21 @@ impl CreateHelpCommand {
self
}
- fn produce_strike_text(&self, dm_or_guild: &str) -> String {
+ fn produce_strike_text(&self, dm_or_guild: &str) -> Option<String> {
let mut strike_text = String::from("~~`Strikethrough commands`~~ are unavailable because they");
+ let mut is_any_option_strike = false;
let mut concat_with_comma = if self.0.lacking_permissions == HelpBehaviour::Strike {
+ is_any_option_strike = true;
let _ = write!(strike_text, " require permissions");
+
true
} else {
false
};
if self.0.lacking_role == HelpBehaviour::Strike {
+ is_any_option_strike = true;
if concat_with_comma {
let _ = write!(strike_text, ", require a specific role");
@@ -239,6 +243,7 @@ impl CreateHelpCommand {
}
if self.0.wrong_channel == HelpBehaviour::Strike {
+ is_any_option_strike = true;
if concat_with_comma {
strike_text.push_str(&format!(", or are limited to {}", dm_or_guild));
@@ -247,7 +252,12 @@ impl CreateHelpCommand {
}
}
let _ = write!(strike_text, ".");
- strike_text
+
+ if is_any_option_strike {
+ Some(strike_text)
+ } else {
+ None
+ }
}
/// Finishes the creation of a help-command, returning `Help`.
@@ -256,13 +266,11 @@ impl CreateHelpCommand {
pub(crate) fn finish(mut self) -> Arc<Help> {
if &self.0.striked_commands_tip_in_dm == &Some(String::new()) {
- let strike_text = self.produce_strike_text("direct messages");
- self.0.striked_commands_tip_in_dm = Some(strike_text);
+ self.0.striked_commands_tip_in_dm = self.produce_strike_text("direct messages");
}
if self.0.striked_commands_tip_in_guild == Some(String::new()) {
- let strike_text = self.produce_strike_text("guild messages");
- self.0.striked_commands_tip_in_guild = Some(strike_text);
+ self.0.striked_commands_tip_in_guild = self.produce_strike_text("guild messages");
}
let CreateHelpCommand(options, function) = self;