mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
[Main] Handle NoPrivateMessage errors
This commit is contained in:
parent
6c53947219
commit
5c13dab8e5
9
red.py
9
red.py
@ -76,24 +76,27 @@ async def on_message(message):
|
|||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
async def on_command_error(error, ctx):
|
async def on_command_error(error, ctx):
|
||||||
|
channel = ctx.message.channel
|
||||||
if isinstance(error, commands.MissingRequiredArgument):
|
if isinstance(error, commands.MissingRequiredArgument):
|
||||||
await send_cmd_help(ctx)
|
await send_cmd_help(ctx)
|
||||||
elif isinstance(error, commands.BadArgument):
|
elif isinstance(error, commands.BadArgument):
|
||||||
await send_cmd_help(ctx)
|
await send_cmd_help(ctx)
|
||||||
elif isinstance(error, commands.DisabledCommand):
|
elif isinstance(error, commands.DisabledCommand):
|
||||||
await bot.send_message(ctx.message.channel,
|
await bot.send_message(channel, "That command is disabled.")
|
||||||
"That command is disabled.")
|
|
||||||
elif isinstance(error, commands.CommandInvokeError):
|
elif isinstance(error, commands.CommandInvokeError):
|
||||||
logger.exception("Exception in command '{}'".format(
|
logger.exception("Exception in command '{}'".format(
|
||||||
ctx.command.qualified_name), exc_info=error.original)
|
ctx.command.qualified_name), exc_info=error.original)
|
||||||
oneliner = "Error in command '{}' - {}: {}".format(
|
oneliner = "Error in command '{}' - {}: {}".format(
|
||||||
ctx.command.qualified_name, type(error.original).__name__,
|
ctx.command.qualified_name, type(error.original).__name__,
|
||||||
str(error.original))
|
str(error.original))
|
||||||
await ctx.bot.send_message(ctx.message.channel, inline(oneliner))
|
await ctx.bot.send_message(channel, inline(oneliner))
|
||||||
elif isinstance(error, commands.CommandNotFound):
|
elif isinstance(error, commands.CommandNotFound):
|
||||||
pass
|
pass
|
||||||
elif isinstance(error, commands.CheckFailure):
|
elif isinstance(error, commands.CheckFailure):
|
||||||
pass
|
pass
|
||||||
|
elif isinstance(error, commands.NoPrivateMessage):
|
||||||
|
await bot.send_message(channel, "That command is not "
|
||||||
|
"available in DMs.")
|
||||||
else:
|
else:
|
||||||
logger.exception(type(error).__name__, exc_info=error)
|
logger.exception(type(error).__name__, exc_info=error)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user