Skip to content

Commit 99379d0

Browse files
committed
Sort commands by permission level in help.
1 parent 6ebfffe commit 99379d0

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

cogs/utility.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,15 @@ async def format_cog_help(self, ctx, cog):
3838

3939
prefix = self.bot.prefix
4040

41+
def perms_required(cmd):
42+
return next(getattr(c, 'permission_level', None) for c in cmd.checks)
43+
4144
fmts = ['']
4245
for cmd in sorted(self.bot.commands,
43-
key=lambda cmd: cmd.qualified_name):
46+
key=lambda cmd: perms_required(cmd)):
4447
if cmd.instance is cog and not cmd.hidden:
4548
new_fmt = f'`{prefix + cmd.qualified_name}` '
46-
perm_level = next(getattr(c, 'permission_level', None) for c in cmd.checks)
49+
perm_level = perms_required(cmd)
4750
if perm_level is not None:
4851
new_fmt = f'`[{perm_level}] {prefix + cmd.qualified_name}` '
4952

@@ -64,12 +67,16 @@ async def format_cog_help(self, ctx, cog):
6467
)
6568

6669
embed.add_field(name='Commands', value=fmt)
67-
embed.set_author(name=cog.__class__.__name__ + ' - Help',
70+
71+
continued = ' (Continued)' if len(embeds) > 0 else ''
72+
73+
embed.set_author(name=cog.__class__.__name__ + ' - Help' + continued,
6874
icon_url=ctx.bot.user.avatar_url)
6975

7076
embed.set_footer(text=f'Type "{prefix}help command" '
7177
'for more info on a command.')
7278
embeds.append(embed)
79+
7380
return embeds
7481

7582
async def format_command_help(self, cmd):

0 commit comments

Comments
 (0)