Correctly get examples, results, and the description
This commit is contained in:
parent
38018674bc
commit
32be71d4ec
12
cogs/misc.py
12
cogs/misc.py
|
@ -60,6 +60,7 @@ class Miscallaneous:
|
||||||
# Assume if there's no description for a command, it's not supposed to be used
|
# Assume if there's no description for a command, it's not supposed to be used
|
||||||
# I.e. the !command command. It's just a parent
|
# I.e. the !command command. It's just a parent
|
||||||
continue
|
continue
|
||||||
|
|
||||||
description = cmd.help.partition('\n')[0]
|
description = cmd.help.partition('\n')[0]
|
||||||
name_fmt = "{ctx.prefix}**{cmd.qualified_name}** {aliases}".format(
|
name_fmt = "{ctx.prefix}**{cmd.qualified_name}** {aliases}".format(
|
||||||
ctx=ctx,
|
ctx=ctx,
|
||||||
|
@ -85,9 +86,8 @@ class Miscallaneous:
|
||||||
description = command.help
|
description = command.help
|
||||||
if description is not None:
|
if description is not None:
|
||||||
# Split into examples, results, and the description itself based on the string
|
# Split into examples, results, and the description itself based on the string
|
||||||
example = [x.replace('EXAMPLE: ', '') for x in description.split('\n') if 'EXAMPLE:' in x]
|
description, _, rest = cmd.help.partition('EXAMPLE:')
|
||||||
result = [x.replace('RESULT: ', '') for x in description.split('\n') if 'RESULT:' in x]
|
example, _, result = rest.partition('RESULT:')
|
||||||
description = [x for x in description.split('\n') if x and 'EXAMPLE:' not in x and 'RESULT:' not in x]
|
|
||||||
else:
|
else:
|
||||||
example = None
|
example = None
|
||||||
result = None
|
result = None
|
||||||
|
@ -98,11 +98,11 @@ class Miscallaneous:
|
||||||
embed = discord.Embed(title=command.qualified_name)
|
embed = discord.Embed(title=command.qualified_name)
|
||||||
embed.set_thumbnail(url=self.bot.user.avatar_url)
|
embed.set_thumbnail(url=self.bot.user.avatar_url)
|
||||||
if description:
|
if description:
|
||||||
embed.add_field(name="Description", value="\n".join(description), inline=False)
|
embed.add_field(name="Description", value=description.strip(), inline=False)
|
||||||
if example:
|
if example:
|
||||||
embed.add_field(name="Example", value="\n".join(example), inline=False)
|
embed.add_field(name="Example", value=example.strip(), inline=False)
|
||||||
if result:
|
if result:
|
||||||
embed.add_field(name="Result", value="\n".join(result), inline=False)
|
embed.add_field(name="Result", value=result.strip(), inline=False)
|
||||||
if subcommands:
|
if subcommands:
|
||||||
embed.add_field(name='Subcommands', value="\n".join(subcommands), inline=False)
|
embed.add_field(name='Subcommands', value="\n".join(subcommands), inline=False)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue