mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
Updated/better command error handling
This commit is contained in:
parent
aefd7c4984
commit
c9e948ae26
14
red.py
14
red.py
@ -2,7 +2,7 @@ from discord.ext import commands
|
||||
import discord
|
||||
from cogs.utils.settings import Settings
|
||||
from cogs.utils.dataIO import dataIO
|
||||
import json
|
||||
from cogs.utils.chat_formatting import inline
|
||||
import asyncio
|
||||
import os
|
||||
import time
|
||||
@ -79,7 +79,17 @@ async def on_command_error(error, ctx):
|
||||
elif isinstance(error, commands.BadArgument):
|
||||
await send_cmd_help(ctx)
|
||||
elif isinstance(error, commands.DisabledCommand):
|
||||
await bot.send_message(ctx.message.channel, "That command is disabled.")
|
||||
await bot.send_message(ctx.message.channel,
|
||||
"That command is disabled.")
|
||||
elif isinstance(error, commands.CommandInvokeError):
|
||||
logger.exception("Exception in command '{}'".format(
|
||||
ctx.command.qualified_name), exc_info=error.original)
|
||||
oneliner = "Error in command '{}' - {}: {}".format(
|
||||
ctx.command.qualified_name, type(error.original).__name__,
|
||||
str(error.original))
|
||||
await ctx.bot.send_message(ctx.message.channel, inline(oneliner))
|
||||
else:
|
||||
logger.exception(type(error).__name__, exc_info=error)
|
||||
|
||||
async def send_cmd_help(ctx):
|
||||
if ctx.invoked_subcommand:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user