Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
hsiW authored and Zeyla Hellyer committed Oct 20, 2017
1 parent 585ac6e commit fbd6258
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions src/framework/standard/help_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fn remove_aliases(cmds: &HashMap<String, CommandOrAlias>) -> HashMap<&String, &I
result
}

/// Checks whether a user is member of required roles
/// Checks whether a user is member of required roles
/// and given the required permissions.
pub fn has_all_requirements(cmd: &Command, msg: &Message) -> bool {
if let Some(guild) = msg.guild() {
Expand All @@ -62,9 +62,9 @@ pub fn has_all_requirements(cmd: &Command, msg: &Message) -> bool {
if let Ok(permissions) = member.permissions() {

if cmd.allowed_roles.is_empty() {
return permissions.administrator() || has_correct_permissions(&cmd, &msg);
return permissions.administrator() || has_correct_permissions(cmd, msg);
} else {
return permissions.administrator() || (has_correct_roles(&cmd, &guild, &member) && has_correct_permissions(cmd, msg));
return permissions.administrator() || (has_correct_roles(cmd, &guild, member) && has_correct_permissions(cmd, msg));
}
}
}
Expand Down Expand Up @@ -111,19 +111,19 @@ pub fn with_embeds(_: &mut Context,
if name == with_prefix || name == *command_name {
match *command {
CommandOrAlias::Command(ref cmd) => {
if has_all_requirements(&cmd, &msg) {
if has_all_requirements(cmd, msg) {
found = Some((command_name, cmd));
}
else {
break;
}
}
},
CommandOrAlias::Alias(ref name) => {
let actual_command = group.commands.get(name).unwrap();
let actual_command = &group.commands[name];

match *actual_command {
CommandOrAlias::Command(ref cmd) => {
if has_all_requirements(&cmd, &msg) {
if has_all_requirements(cmd, msg) {
found = Some((name, cmd));
}
else {
Expand Down Expand Up @@ -230,12 +230,9 @@ pub fn with_embeds(_: &mut Context,
for name in command_names {
let cmd = &commands[name];

if cmd.help_available {

if cmd.help_available && has_all_requirements(&cmd, &msg) {
let _ = write!(desc, "`{}`\n", name);
has_commands = true;
}
if cmd.help_available && has_all_requirements(cmd, msg) {
let _ = write!(desc, "`{}`\n", name);
has_commands = true;
}
}

Expand Down Expand Up @@ -289,19 +286,19 @@ pub fn plain(_: &mut Context,
if name == with_prefix || name == *command_name {
match *command {
CommandOrAlias::Command(ref cmd) => {
if has_all_requirements(&cmd, &msg) {
if has_all_requirements(cmd, msg) {
found = Some((command_name, cmd));
}
else {
break;
}
},
CommandOrAlias::Alias(ref name) => {
let actual_command = group.commands.get(name).unwrap();
let actual_command = &group.commands[name];

match *actual_command {
CommandOrAlias::Command(ref cmd) => {
if has_all_requirements(&cmd, &msg) {
if has_all_requirements(cmd, msg) {
found = Some((name, cmd));
}
else {
Expand Down Expand Up @@ -390,7 +387,7 @@ pub fn plain(_: &mut Context,
for name in command_names {
let cmd = &commands[name];

if cmd.help_available && has_all_requirements(&cmd, &msg) {
if cmd.help_available && has_all_requirements(cmd, msg) {
let _ = write!(group_help, "`{}` ", name);
}
}
Expand Down

0 comments on commit fbd6258

Please sign in to comment.