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
This commit is contained in:
jack1142 2021-01-23 21:49:03 +01:00 committed by GitHub
parent ad48ef6efd
commit 991cd46ea3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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"