From 991cd46ea3dc9c38593fa7e3fc9cf69e0d62fe36 Mon Sep 17 00:00:00 2001 From: jack1142 <6032823+jack1142@users.noreply.github.com> Date: Sat, 23 Jan 2021 21:49:03 +0100 Subject: [PATCH] Add non-generic message when loading a cog with command name that is already registered (#3870) * Add non-generic message when loading a cog with command name that is already registered * Use regex instead and add i18n support * This requires d.py 1.4 --- redbot/core/core_commands.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/redbot/core/core_commands.py b/redbot/core/core_commands.py index 516e5c28f..7dd54e6de 100644 --- a/redbot/core/core_commands.py +++ b/redbot/core/core_commands.py @@ -174,6 +174,20 @@ class CoreLogic: except errors.CogLoadError as e: failed_with_reason_packages.append((name, str(e))) except Exception as e: + if isinstance(e, commands.CommandRegistrationError): + if e.alias_conflict: + error_message = _( + "Alias {alias_name} is already an existing command" + " or alias in one of the loaded cogs." + ).format(alias_name=inline(e.name)) + else: + error_message = _( + "Command {command_name} is already an existing command" + " or alias in one of the loaded cogs." + ).format(command_name=inline(e.name)) + failed_with_reason_packages.append((name, error_message)) + continue + log.exception("Package loading failed", exc_info=e) exception_log = "Exception during loading of package\n"