Editing of custom commands, add posix flags

This commit is contained in:
stijndcl 2022-06-25 01:57:52 +02:00
parent 257eae6fa7
commit d6a560851b
9 changed files with 184 additions and 22 deletions

View file

@ -65,3 +65,23 @@ async def get_command_by_alias(session: AsyncSession, message: str) -> Optional[
return None
return alias.command
async def edit_command(
session: AsyncSession, original_name: str, new_name: Optional[str] = None, new_response: Optional[str] = None
) -> CustomCommand:
"""Edit an existing command"""
# Check if the command exists
command = await get_command(session, original_name)
if command is None:
raise NoResultFoundException
if new_name is not None:
command.name = new_name
if new_response is not None:
command.response = new_response
session.add(command)
await session.commit()
return command