[V3 Help] Fix help for unknown commands (#1137)

This commit is contained in:
Will 2017-12-03 18:02:03 -05:00 committed by GitHub
parent e6086bb7b3
commit 9a98d5aa8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -250,23 +250,23 @@ class Help(formatter.HelpFormatter):
return ret return ret
@staticmethod def simple_embed(self, ctx, title=None, description=None, color=None):
def simple_embed(ctx, title=None, description=None, color=None, author=None):
# Shortcut # Shortcut
self.context = ctx
if color is None:
color = self.color
embed = discord.Embed(title=title, description=description, color=color) embed = discord.Embed(title=title, description=description, color=color)
embed.set_footer(text=ctx.bot.formatter.get_ending_note()) embed.set_footer(text=ctx.bot.formatter.get_ending_note())
if author: embed.set_author(**self.author)
embed.set_author(**author)
return embed return embed
@staticmethod def cmd_not_found(self, ctx, cmd, color=None):
def cmd_not_found(ctx, cmd, color=0):
# Shortcut for a shortcut. Sue me # Shortcut for a shortcut. Sue me
embed = Help.simple_embed( embed = self.simple_embed(
ctx, ctx,
title=ctx.bot.command_not_found.format(cmd), title=ctx.bot.command_not_found.format(cmd),
description='Commands are case sensitive. Please check your spelling and try again', description='Commands are case sensitive. Please check your spelling and try again',
color=color, author=ctx.author) color=color)
return embed return embed
@ -294,7 +294,7 @@ async def help(ctx, *cmds: str):
command = ctx.bot.all_commands.get(name) command = ctx.bot.all_commands.get(name)
if command is None: if command is None:
await destination.send( await destination.send(
embed=Help.cmd_not_found(ctx, name, ctx.bot.formatter.color)) embed=ctx.bot.formatter.cmd_not_found(ctx, name))
return return
embeds = await ctx.bot.formatter.format_help_for(ctx, command) embeds = await ctx.bot.formatter.format_help_for(ctx, command)
@ -302,7 +302,8 @@ async def help(ctx, *cmds: str):
name = _mention_pattern.sub(repl, cmds[0]) name = _mention_pattern.sub(repl, cmds[0])
command = ctx.bot.all_commands.get(name) command = ctx.bot.all_commands.get(name)
if command is None: if command is None:
await destination.send(embed=Help.cmd_not_found(ctx, name, ctx.bot.formatter.color)) await destination.send(
embed=ctx.bot.formatter.cmd_not_found(ctx, name))
return return
for key in cmds[1:]: for key in cmds[1:]:
@ -311,11 +312,11 @@ async def help(ctx, *cmds: str):
command = command.all_commands.get(key) command = command.all_commands.get(key)
if command is None: if command is None:
await destination.send( await destination.send(
embed=Help.cmd_not_found(ctx, key, ctx.bot.formatter.color)) embed=ctx.bot.formatter.cmd_not_found(ctx, key))
return return
except AttributeError: except AttributeError:
await destination.send( await destination.send(
embed=Help.simple_embed( embed=ctx.bot.formatter.simple_embed(
ctx, ctx,
title='Command "{0.name}" has no subcommands.'.format(command), title='Command "{0.name}" has no subcommands.'.format(command),
color=ctx.bot.formatter.color, color=ctx.bot.formatter.color,