diff options
| author | Maiddog <[email protected]> | 2017-05-24 19:20:04 -0500 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-05-24 17:20:04 -0700 |
| commit | 93416cdebff12a3f85e694c8cb28350a5c14c50f (patch) | |
| tree | 0280c2b316bb29e104d8c7a238e3fcd4dc7793b3 /src/framework | |
| parent | Support adding reactions when creating message (diff) | |
| download | serenity-93416cdebff12a3f85e694c8cb28350a5c14c50f.tar.xz serenity-93416cdebff12a3f85e694c8cb28350a5c14c50f.zip | |
Sort default help by group/command names
Sort the default framework help functions by their group and command
names.
This should act as a reasonable default for users. If other behaviour is
required, users can make their own or copy and modify existing functions.
Diffstat (limited to 'src/framework')
| -rw-r--r-- | src/framework/help_commands.rs | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/framework/help_commands.rs b/src/framework/help_commands.rs index 1f38bd5..5d9a1f6 100644 --- a/src/framework/help_commands.rs +++ b/src/framework/help_commands.rs @@ -146,7 +146,11 @@ pub fn with_embeds(ctx: &mut Context, .description("To get help with an individual command, pass its \ name as an argument to this command."); - for (group_name, group) in groups { + let mut group_names = groups.keys().collect::<Vec<_>>(); + group_names.sort(); + + for group_name in group_names { + let group = &groups[group_name]; let mut desc = String::new(); if let Some(ref x) = group.prefix { @@ -155,9 +159,15 @@ pub fn with_embeds(ctx: &mut Context, let mut no_commands = true; - for (n, cmd) in remove_aliases(&group.commands) { + let commands = remove_aliases(&group.commands); + let mut command_names = commands.keys().collect::<Vec<_>>(); + command_names.sort(); + + for name in command_names { + let cmd = &commands[name]; + if cmd.help_available { - let _ = write!(desc, "`{}`\n", n); + let _ = write!(desc, "`{}`\n", name); no_commands = false; } @@ -255,7 +265,11 @@ pub fn plain(ctx: &mut Context, name as an argument to this command.\n\n" .to_string(); - for (group_name, group) in groups { + let mut group_names = groups.keys().collect::<Vec<_>>(); + group_names.sort(); + + for group_name in group_names { + let group = &groups[group_name]; let _ = write!(result, "**{}:** ", group_name); if let Some(ref x) = group.prefix { @@ -264,9 +278,15 @@ pub fn plain(ctx: &mut Context, let mut no_commands = true; - for (n, cmd) in remove_aliases(&group.commands) { + let commands = remove_aliases(&group.commands); + let mut command_names = commands.keys().collect::<Vec<_>>(); + command_names.sort(); + + for name in command_names { + let cmd = &commands[name]; + if cmd.help_available { - let _ = write!(result, "`{}` ", n); + let _ = write!(result, "`{}` ", name); no_commands = false; } |