Fixed addcommand conflict messaging for non-custom commands.
CI / Formatting (push) Successful in 5s
CI / Linting (push) Successful in 5s
CI / Tests (Python 3.12) (push) Successful in 2m57s
CI / Tests (Python 3.13) (push) Successful in 2m56s
CI / Tests (Python 3.14) (push) Successful in 2m49s
CI / Type Checking (push) Successful in 9s
CI / Spelling (push) Successful in 4s
CI / Formatting (push) Successful in 5s
CI / Linting (push) Successful in 5s
CI / Tests (Python 3.12) (push) Successful in 2m57s
CI / Tests (Python 3.13) (push) Successful in 2m56s
CI / Tests (Python 3.14) (push) Successful in 2m49s
CI / Type Checking (push) Successful in 9s
CI / Spelling (push) Successful in 4s
This commit is contained in:
@@ -74,6 +74,17 @@ async def addcommand(ctx: CommandContext) -> None:
|
||||
f"Use '{prefix}editcommand' to modify it."
|
||||
)
|
||||
return
|
||||
except NotCustomCommandError:
|
||||
await ctx.owncast_client.send_message(
|
||||
"That command is not a custom command and cannot be modified."
|
||||
)
|
||||
return
|
||||
except InactiveCommandError as e:
|
||||
await ctx.owncast_client.send_message(
|
||||
f"Custom command {prefix}{e.name} is disabled because another module "
|
||||
f"registered the same name. Delete it or resolve the conflict to re-enable."
|
||||
)
|
||||
return
|
||||
|
||||
await ctx.owncast_client.send_message(f"Command {prefix}{cmd.name} created.")
|
||||
|
||||
|
||||
@@ -156,11 +156,19 @@ class CommandManager:
|
||||
:param response: Response template.
|
||||
:return: Snapshot of the created command.
|
||||
:raises InvalidNameError: If name is invalid.
|
||||
:raises CommandAlreadyExistsError: If name conflicts with any command.
|
||||
:raises CommandAlreadyExistsError: If name conflicts with a custom command.
|
||||
:raises NotCustomCommandError: If name conflicts with a non-custom command.
|
||||
:raises InactiveCommandError: If name conflicts with an inactive custom command.
|
||||
"""
|
||||
if not NAME_RE.match(name):
|
||||
raise InvalidNameError(name)
|
||||
if self._commands.exists(name):
|
||||
try:
|
||||
command = await self._repo.get(name)
|
||||
except CommandNotFoundError as err:
|
||||
raise NotCustomCommandError(name) from err
|
||||
if self._commands.get(command.name) is None:
|
||||
raise InactiveCommandError(command.name)
|
||||
raise CommandAlreadyExistsError(name)
|
||||
|
||||
default_cooldown: int = self._ctx.config.get("default_cooldown", 5)
|
||||
|
||||
Reference in New Issue
Block a user