Skip to content

Commit

Permalink
Show command documentation when commands are used incorrectly
Browse files Browse the repository at this point in the history
  • Loading branch information
Iapetus-11 committed Jul 16, 2024
1 parent ce3f393 commit e7eb026
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions bot/cogs/core/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,31 @@ async def on_command_error(self, ctx: Ctx, e: Exception):
elif isinstance(e, commands.MaxConcurrencyReached | MaxKarenConcurrencyReached):
await ctx.reply_embed(ctx.l.misc.errors.nrn_buddy, ignore_exceptions=True)
elif isinstance(e, commands.MissingRequiredArgument):
await ctx.reply_embed(ctx.l.misc.errors.missing_arg, ignore_exceptions=True)
command_doc = {
**ctx.l.help.econ,
**ctx.l.help.mc,
**ctx.l.help.util,
**ctx.l.help.fun,
**ctx.l.help.mod,
}.get(str(ctx.command), ctx.l.help.main.nodoc).format(ctx.prefix)

await ctx.reply_embed(
f"{ctx.l.misc.errors.missing_arg}\n\n{ctx.l.help.n.cmd}:\n{command_doc}",
ignore_exceptions=True,
)
elif isinstance(e, BAD_ARG_ERRORS):
await ctx.reply_embed(ctx.l.misc.errors.bad_arg, ignore_exceptions=True)
command_doc = {
**ctx.l.help.econ,
**ctx.l.help.mc,
**ctx.l.help.util,
**ctx.l.help.fun,
**ctx.l.help.mod,
}.get(str(ctx.command), ctx.l.help.main.nodoc).format(ctx.prefix)

await ctx.reply_embed(
f"{ctx.l.misc.errors.missing_arg}\n\n{ctx.l.help.n.cmd}:\n{command_doc}",
ignore_exceptions=True,
)
elif hasattr(ctx, "failure_reason") and ctx.failure_reason: # handle global check failures
failure_reason = ctx.failure_reason

Expand Down

0 comments on commit e7eb026

Please sign in to comment.