@@ -27,47 +27,29 @@ def __init__(self, bot):
27
27
28
28
def format_cog_help (self , ctx , cog ):
29
29
"""Formats the text for a cog help"""
30
- sigs = []
30
+
31
+ maxlen = 0
31
32
prefix = self .bot .prefix
32
33
33
34
for cmd in self .bot .commands :
34
35
if cmd .hidden :
35
36
continue
36
37
if cmd .instance is cog :
37
- sigs .append (len (cmd .qualified_name ) + len (prefix ))
38
- if hasattr (cmd , 'all_commands' ):
39
- for c in cmd .all_commands .values ():
40
- sigs .append (len ('\u200b └─ ' + c .name ) + 1 )
38
+ len_ = len (cmd .qualified_name ) + len (prefix )
39
+ if len_ > maxlen :
40
+ maxlen = len_
41
41
42
- if not sigs :
42
+ if maxlen == 0 :
43
43
return
44
44
45
- maxlen = max (sigs )
46
-
47
- fmt = ['' ]
48
- index = 0
45
+ fmt = ''
49
46
for cmd in self .bot .commands :
50
47
if cmd .instance is cog :
51
48
if cmd .hidden :
52
49
continue
53
- if len (f'{ fmt [index ]} `{ prefix + cmd .qualified_name :<{maxlen }} ` '
54
- f'- { cmd .short_doc :<{maxlen }} \n ' ) > 1024 :
55
- index += 1
56
- fmt .append ('' )
57
- fmt [index ] += f'`{ prefix + cmd .qualified_name :<{maxlen }} ` - '
58
- fmt [index ] += f'{ cmd .short_doc :<{maxlen }} \n '
59
- if hasattr (cmd , 'commands' ):
60
- for i , c in enumerate (cmd .commands ):
61
- if len (cmd .commands ) == i + 1 : # last
62
- branch = '\u200b └─ ' + c .name
63
- else :
64
- branch = '\u200b ├─ ' + c .name
65
- if len (f'{ fmt [index ]} `{ branch :<{maxlen + 1 }} ` - '
66
- f'{ c .short_doc :<{maxlen }} \n ' ) > 1024 :
67
- index += 1
68
- fmt .append ('' )
69
- fmt [index ] += f'`{ branch :<{maxlen + 1 }} ` - '
70
- fmt [index ] += f'{ c .short_doc :<{maxlen }} \n '
50
+
51
+ fmt += f'`{ prefix + cmd .qualified_name :<{maxlen }} ` - '
52
+ fmt += f'{ cmd .short_doc :<{maxlen }} \n '
71
53
72
54
em = Embed (
73
55
description = '*' + inspect .getdoc (cog ) + '*' ,
@@ -76,13 +58,10 @@ def format_cog_help(self, ctx, cog):
76
58
em .set_author (name = cog .__class__ .__name__ + ' - Help' ,
77
59
icon_url = ctx .bot .user .avatar_url )
78
60
79
- for n , i in enumerate (fmt ):
80
- if n == 0 :
81
- em .add_field (name = 'Commands' , value = i )
82
- else :
83
- em .add_field (name = u'\u200b ' , value = i )
61
+ em .add_field (name = 'Commands' , value = fmt )
84
62
85
- em .set_footer (text = f'Type { prefix } command for more info on a command.' )
63
+ em .set_footer (text = f'Type "{ prefix } command" '
64
+ 'for more info on a command.' )
86
65
return em
87
66
88
67
def format_command_help (self , ctx , cmd ):
@@ -115,7 +94,7 @@ def format_command_help(self, ctx, cmd):
115
94
116
95
em .add_field (name = 'Sub-commands' , value = fmt )
117
96
em .set_footer (
118
- text = f'Type { prefix } help { cmd } command for more info on a command.'
97
+ text = f'Type " { prefix } help { cmd } " for more info on a command.'
119
98
)
120
99
return em
121
100
@@ -125,7 +104,7 @@ def format_not_found(self, ctx, command):
125
104
title = 'Could not find a cog or command by that name.' ,
126
105
color = Color .red ()
127
106
)
128
- em .set_footer (text = f'Type { prefix } help to get '
107
+ em .set_footer (text = f'Type " { prefix } help" to get '
129
108
'a full list of commands.' )
130
109
cogs = get_close_matches (command , self .bot .cogs .keys ())
131
110
cmds = get_close_matches (command , self .bot .all_commands .keys ())
@@ -140,11 +119,10 @@ def format_not_found(self, ctx, command):
140
119
return em
141
120
142
121
@commands .command ()
122
+ @trigger_typing
143
123
async def help (self , ctx , * , command : str = None ):
144
124
"""Shows the help message."""
145
125
146
- await ctx .trigger_typing ()
147
-
148
126
if command is not None :
149
127
cog = self .bot .cogs .get (command )
150
128
cmd = self .bot .get_command (command )
0 commit comments