diff --git a/redbot/core/core_commands.py b/redbot/core/core_commands.py index a856205e4..d52b8c710 100644 --- a/redbot/core/core_commands.py +++ b/redbot/core/core_commands.py @@ -3,6 +3,7 @@ import importlib import itertools import logging import sys +import traceback from collections import namedtuple from random import SystemRandom from string import ascii_letters, digits @@ -229,6 +230,13 @@ class Core: await ctx.bot.load_extension(spec) except Exception as e: log.exception("Package loading failed", exc_info=e) + + exception_log = ("Exception in command '{}'\n" + "".format(ctx.command.qualified_name)) + exception_log += "".join(traceback.format_exception(type(e), + e, e.__traceback__)) + self.bot._last_exception = exception_log + await ctx.send(_("Failed to load package. Check your console or " "logs for details.")) else: @@ -264,6 +272,13 @@ class Core: await ctx.bot.load_extension(spec) except Exception as e: log.exception("Package reloading failed", exc_info=e) + + exception_log = ("Exception in command '{}'\n" + "".format(ctx.command.qualified_name)) + exception_log += "".join(traceback.format_exception(type(e), + e, e.__traceback__)) + self.bot._last_exception = exception_log + await ctx.send(_("Failed to reload package. Check your console or " "logs for details.")) else: