Create command to list custom commands, add shortcuts to memegen commands

This commit is contained in:
stijndcl 2022-09-23 18:06:33 +02:00
parent 8922489a41
commit bf32a5ef47
8 changed files with 120 additions and 62 deletions

View file

@ -12,6 +12,7 @@ __all__ = [
"create_alias",
"create_command",
"edit_command",
"get_all_commands",
"get_command",
"get_command_by_alias",
"get_command_by_name",
@ -55,6 +56,12 @@ async def create_alias(session: AsyncSession, command: str, alias: str) -> Custo
return alias_instance
async def get_all_commands(session: AsyncSession) -> list[CustomCommand]:
"""Get a list of all commands"""
statement = select(CustomCommand)
return (await session.execute(statement)).scalars().all()
async def get_command(session: AsyncSession, message: str) -> Optional[CustomCommand]:
"""Try to get a command out of a message"""
# Search lowercase & without spaces